Hi,
I've been struggling to find a solution to this one, any help appreciated!
Say I created a file using the following code, and my array has 5 entries (i.e. EClub.Length = 5)
Function ClubsSaveToDevice()
rem if save file exists, delelte it first
If GetFileExists("EditClubsSave.txt")=1
DeleteFile("EditClubsSave.txt")
EndIF
rem save game
fileID = openToWrite("EditClubsSave.txt", 0)
if fileIsOpen(FileID) = 1
rem clubs details
For i = 0 to EClub.Length
writeString(fileID, EClub[i].Name)
writeString(fileID, EClub[i].ID)
writeString(fileID, EClub[i].pword)
writeString(fileID, EClub[i].package)
writeInteger(fileID, EClub[i].clubtype)
Next i
closeFile(fileID)
EndIF
EndFunction
How can I then read in the data when it won't know that there is 5 entries in the array? I've tried using a repeat until but I just get an error saying the Array is out of bounds.
Function ClubsLoadToDevice()
rem if save file exists, delelte it first
If GetFileExists("EditClubsSave.txt")=1
fileID = openToRead("EditClubsSave.txt")
if fileIsOpen(FileID) = 1
rem clubs details
i = 0
repeat
EClub[i].Name = ReadString(fileID)
EClub[i].ID = ReadString(fileID)
EClub[i].pword = ReadString(fileID)
EClub[i].package = ReadString(fileID)
EClub[i].clubtype = ReadInteger(fileID)
inc i
until fileEOF(FileID) > 0
closeFile(fileID)
EndIF
EndIF
EndFunction
El Presidente