Hello, I am trying to write from a table to an existing file. But "OpenFile" fails to open the existing file. Here is what I try to do:
Code: Select all
Function p_ScoreOpener(mode)
Local f_exists
Switch scoreclass
Case 0:
f_exists = Exists("scr/attack0.scr")
if f_exists = TRUE
OpenFile(1,"scr/attack0.scr",mode)
endif
Case 1:
f_exists = Exists("scr/attack1.scr")
if f_exists = TRUE
OpenFile(1,"scr/attack1.scr",mode)
endif
Case 2:
f_exists = Exists("scr/attack2.scr")
if f_exists = TRUE
OpenFile(1,"scr/attack2.scr",mode)
endif
EndSwitch
return (f_exists)
EndFunction
Function p_FillScoreTab()
if p_ScoreOpener(#MODE_READ) = TRUE
Seek(1,0)
Local i = 0
While NOT EOF(1)
scoretab[i][0] = ReadLine(1)
scoretab[i][1] = ReadLine(1)
i = add(i,1)
Wend
CloseFile(1)
endif
EndFunction
Function p_SaveScores()
if p_ScoreOpener(#MODE_READWRITE) = TRUE
Seek(1,0)
for i = 0 To 9
if scoretab[i][0] <> ""
WriteLine(1,scoretab[i][0])
WriteLine(1,scoretab[i][1])
endif
Next
CloseFile(1)
endif()
EndFunction
Function p_CheckScores()
changed = 0
scoreclass = difficulty
p_FillScoreTab()
Local count = 9
for i = 0 To count
if scoretab[i][0] = NULL
p_UpdateEntry()
Break()
elseif Score > scoretab[i][1]
for k = count-1 to i Step -1
scoretab[k][0] = scoretab[k-1][0]
scoretab[k][1] = scoretab[k-1][1]
Next
p_UpdateEntry()
Break()
endif
Next
If changed = 1
p_SaveScores()
endif
EndFunction