Webcore - How do I determine EOF when reading a text file and how do I get out of the for loop when that happens?

I am reading a text file of song data...

artist - title
artist - title
artist - title

How do I know that I have reached the EOF? Should I use a For loop? How do I get out of that at EOF?

Havenโ€™t played with file in webCoRE for a while, but want to say that I set a variable to the size of the text returned initially and then used a loop to parse the returned text until my index was >= the orignal text size.

1 Like

I spent hours last night trying to load a text array, reading an unknown number of data elements from a text file into the array. I kept getting errors near the end of the data file. I believe I am trying to reference data outside of the data file on the last For loop index. I thought that the parse would return -1, indicating EOF, thus signaling that all of the data had been read. But I just could not get the syntax correct to end my For loop, thus creating my error. I have resigned to counting the number of elements in the data file and using that variable in my For loop. But I would prefer not to do it that way.

Will a For loop take a Conditional statement (End_Of_File = true) in the loop?

Looks like that should work, alternatively you could try ending it when
Parse_Index < 0

Maybe a while Parse_Index > -1 instead of the for

It did not like the boolean For loop condition.

I will try that next.

While loop works perfectly.

1 Like