I'm having a hard time with this...
I got it working ith Fred code... but with a single output/input file. I place my readstrings loop inside the readfilecallback() and it works but...
the problem is that my original code wants to write and read 7 files (each file has a player name and scores). And I can not have it working.
Something like this:
Code: Select all
Dim name$(7)
Procedure Callback(Status, Filename$, File, SizeRead)
Select Status
Case #PB_Status_Saved
; File correctly saved
Case #PB_Status_Error
; File saving has failed
EndSelect
EndProcedure
For j=0 To 7
If CreateFile(0, "p"+Str(j), @Callback(),#PB_LocalStorage) ; we create a new text file
WriteStringN(0, "Player Name "+Str(j))
;write scores blah blah blah
CloseFile(0)
EndIf
Next
For j=0 To 7
ReadFile(0,"p"+Str(j),@Callback(),#PB_LocalStorage)
name$(j)=ReadString(0):Debug name$(j)
;read scores blah blah blah
CloseFile(0)
Next
PS: I know it is not working. This code is just "what I want to do", not "how to do it"
The idea is that my program will save all the player names and scores every time they change, so if the browser crash or the app reloads, it will start reading the last saved player names and scores, to continue were it was left:
Code: Select all
START: PSEUDO CODE
readscores()
fillscreen()
repeat ;main loop
if score=change
savesccores():fillscreen()
endif
forever