ARGH> I was using a Write/Read routine that was successfully saving all my high scores to a single DAT file. it worked for a little over a day, then all of a sudden just stopped working. it stopped reading or writing the DAT file somehow, even though NO CODE HAS BEEN CHANGED!
I tried the program on two other computers (3 total), and it won't save a DAT file on any of them now. So the game will show the high score at the end of the game now, but then when you exit, it won't pull them back up because the is no longer a DAT file. (I deleted ALL of the DAT files with the same filename on my PC, including in the recycle bin to try and resolve it somehow, but now the game won't even make a DAT file anymore.
Makes NO sense how it works perfectly for 30 games then all of a sudden just stopped saving and reading the DAT file.
Here is what I have at the beginning of my program:
Dim HS$(10)
Dim HISCORE(10)
Dim HIDOLLAR(10)
Dim HICENTS(10)
Dim HIBONUS(10)
Dim AVGTMP(10
Filename$="LemonHi.DAT"
If File Exist(Filename$)
Open To Read 1,Filename$
For N=1 To 10
Read String 1,T$: HS$(N)=T$
Read String 1,T$: Hiscore(N)=Val(T$)
Read String 1,T$: HIDOLLAR(n)=val(t$)
Read String 1,T$: HICENTS(n)=val(t$)
Read String 1,T$: HIBONUS(n)=val(t$)
Read String 1,T$: AVGTMP(n)=val(t$)
Next N
Close File 1
Else
Open To Write 1,Filename$
For N=1 To 10
Write String 1,HS$(N)
Write String 1,Str$(Hiscore(N))
Write String 1,T$: HIDOLLAR(n)=val(t$)
Write String 1,T$: HICENTS(n)=val(t$)
Write String 1,T$: HIBONUS(n)=val(t$)
Write String 1,T$: AVGTMP(n)=val(t$)
Next N
Close File 1
Endif
- And then at the end of the game I have this which sorts and saves the data after deleting the old file...
spot=0
for z=10 to 1 step -1
if score>HISCORE(z) then spot=z
next z
if spot=0 then goto showscores:
pl=spot+1
for z=10 to pl step -1
HISCORE(z)=HISCORE(z-1):HS$(z)=HS$(z-1)
HIDOLLAR(z)=HIDOLLAR(z-1):HICENTS(z)=HICENTS(z-1)
HIBONUS(z)=HIBONUS(z-1):AVGTMP(z)=AVGTMP(z-1)
next z
HISCORE(spot)=score:HS$(spot)=N$
HIDOLLAR(spot)=DL:HICENTS(spot)=cn
HIBONUS(spot)=tbn:AVGTMP(spot)=avt
Delete File FileName$
Open To Write 1,Filename$
For N=1 To 10
Write String 1,HS$(N)
Write String 1,Str$(Hiscore(N))
Write String 1,Str$(Hidollar(N))
Write String 1,str$(Hicents(n))
Write String 1,str$(HiBonus(N))
Write String 1,str$(AVGTMP(n))
Next N
Close File 1
I'm pulling my hair out here. I am running windows XP on this PC, and Windows 7 on the other two computers I tried it on, and I clicked the run as admin on the properties as well on the Win 7 computers.
I have tripled checked to code to make sure it isn't skipping it somehow, but it is reading all the data, and printing the players score as the top one now.
..Like I said, it WAS working for about 30 games or so, then just magically stopped with no code changes to the program.
Any help or ideas would be appreciated.. mostly to help me understand what might be wrong and lower my frustration with DarkBasic at the moment.
- Zaxx