Quote: "it would read the next line in the txt file?"
yes, assuming there was one. if you know how many lines there are to read, that should be fine.
otherwise, if the lines were unknown (no idea what your project is), something like:
TheseLines as String []
ThisFile = OpenToRead("thisdata.txt")
Repeat
TheseLines.Insert( ReadLine(ThisFile) )
Until FileEOF( ThisFile )
CloseFile(ThisFile)
do
for x = 0 to TheseLines.Length
Print(TheseLines[x])
next x
Sync()
loop
then manipulate/do what you want with those strings.
meanwhile, for the 2nd part of the first post:
If GetFileExists("this.data") = 0
ThisFile = OpenToWrite("this.data")
WriteInteger(ThisFile,10)
WriteFloat(ThisFile,1.23)
WriteString(ThisFile,"hello")
CloseFile(ThisFile)
Endif
ThisFile = OpenToRead("this.data")
a = ReadInteger ( ThisFile )
b# = ReadFloat ( ThisFile )
c$ = ReadString ( ThisFile )
CloseFile ( ThisFile )
do
Print(a)
Print(b#)
print(c$)
Sync()
loop
bonus material: building and parsing strings can be handy. in my 2d billiards, the top ten scores, times and dates are all held in 1 string (as is the version number):
Build the String from a Typed array (Scores)
Function UpdateHighScoreVariable()
HSString$ = Version$ + "|"
For x = 0 to 9 //Build HSString$
ThisScore$ = STR(Scores[x].Shots,0)
ThisTime$ = STR(Scores[x].Seconds,0)
ThisDate$ = Scores[x].Date
HSString$ = HSString$ + ThisScore$ + ":" + ThisTime$ + ":" + ThisDate$
If x < 9 then HSString$ = HSString$+"|"
next x
SaveHighScore()
EndFunction
Save the String (HSString$, as cookie or otherwise):
Function SaveHighScore()
If IsHTML = 1
If CookiesEnabled = 1
SaveSharedVariable(HSSharedVariableName$,HSString$)
Endif
Else `is NOT HTML
ThisFile = OpenToWrite(HSFile$)
WriteString(ThisFile,HSString$)
CloseFile(ThisFile)
Endif
EndFunction
Parsing the String (fill in the top 10 scores, after loading it):
Function ParseHSString()
ThisVersion$ = GetStringToken(HSString$,"|",1)
For x = 0 to 9
ThisEntry$ = GetStringToken(HSString$,"|",x+2)
Scores[x].Shots = VAL(GetStringToken(ThisEntry$,":",1))
Scores[x].Seconds = VAL(GetStringToken(ThisEntry$,":",2))
Scores[x].Date = GetStringToken(ThisEntry$,":",3)
Next x
EndFunction
[
My Itch.io Home]
[
CODE lang=AGK
] Your Code Here [/
CODE]
[
VIDEO=youtube
] VideoID [/
VIDEO]