Posted: 14th Sep 2011 19:34
i want to do a loop that will do a readline until it returns no value, away from my pc that has it on it so was wondering if this would work


string$ = ""


repeat

string$ = ReadLine(.....)

until string$ = ""

is this way doable??

or is there something that is or even better?

trying to read lines until the line returns no string
Posted: 14th Sep 2011 19:55
Read the help for file commands....

integer FileEOF( iFileID )
Posted: 14th Sep 2011 20:10
saw that thanks,

but i was toying with the idea of having one file split up by one extra return so it would read til it returned no text value, then the next level it would dismiss all until it got to the no text value then continue until it got the next,, etc etcc.. kina liek a cheap xml for the time being.


example

levels.txt

would contain

Collect 6 Rocks
Collect 10 loads of dry grass
Collect 10 Loads of wood
Light Fire

Collect 100 Rocks
Shape Shovels

Collect 60 Loads of Rocks
Collect 20 Loads of Mud
Collect 15 Loads of Wood
Build Well



so if on the first level i would read the requirements

Collect 6 Rocks
Collect 10 loads of dry grass
Collect 10 Loads of wood
Light Fire

and stop,

then for level two would read the requirements

Collect 100 Rocks
Shape Shovels

etc etc etc..
Posted: 14th Sep 2011 20:16
You might be better off formatting your file like an old school ini file:
[level1]
Collect 6 Rocks
..blah blah..
[level2]
Collect 100 Rocks
..blah blah..

You read the file a line at a line at a time until you reach the [levelx] section you want. Import all of that data and keep reading the file until you reach the next [levelx] section.
Posted: 14th Sep 2011 20:45
Your approach seems doable. Since you may have more than one empty line, you should probably put a marker at the end of the file, like say, "END". Then when your input string = "END" you can close the file.

But integer FileEOF( iFileID ) works just as well.

And Bursar's approach would work, and so would XML formatted files, as long as you write your own XML reading code.

You could just try all the available methods, see which one you like best, really.
Posted: 14th Sep 2011 22:14
so would XML formatted files, as long as you write your own XML reading code.

That's the reason I didn't suggest it. It would be a lot more powerful, but a load more work to get working correctly.
Posted: 15th Sep 2011 21:04
does FileEOF work in tier 2... im using

nFileComplete is initialized to 0 its a global variable initialized on program startup.

the code looks like

agk:penToRead(1, "currentMission.txt");

while (1 != nFileComplete) {
char* c = agk::ReadLine(1);
nFileComplete == agk::FileEOF(1);
}

however agk::FileEOF(1); continues to return a 0 every time. no matter if the readline returns a value or when theres no more to read and doesnt return value
Posted: 15th Sep 2011 21:07
ha never thought to read the documentation on readline

you use this command in tier 2 you must delete the returned string when you are finsihed with it.


so delete the char *c value?