How can this happen?

BlitzPlus Forums/BlitzPlus Beginners Area/How can this happen?

Zooker(Posted 2006) [#1]
Is this a Bug in early Blitz version
;Initialise some variables For the example
Type HighScore
Field Name$
Field Score%
Field Level%
End Type

Best.HighScore = New HighScore
Best\Name = "Howard Colbourne"
Best\Score = 50005
Best\Level = 34

; Open a file to write to
fileout = WriteFile("Dumbdata.dat")

; Write the information to the file
WriteString( fileout, Best\Name )
WriteInt( fileout, Best\Score )
WriteByte( fileout, Best\Level )

; Close the file
CloseFile( fileout )
Best\Score = ""
;Open the file To Read
filein = ReadFile("Dumbdata.dat")
; Lets read the Greatest score from the file
Best\Name$ = ReadString$( filein )
Best\Score = ReadInt( filein )
Best\Level = ReadByte( filein )
Print "High score record read from - Dumbdata.dat "
Print
Write "Name = "
Print Best\Name
Write "Score = "
Print Best\Score
Write "Level = "
Print Best\Level
CloseFile( fileout )< It reads & writes correctly but when it hits this command it comes up[File does not exist] How can it say that after it just got thru reading the darn file?

WaitKey()

?


DjBigWorm(Posted 2006) [#2]
Hey,

It is late and I took a glance at your code
in line
filein = ReadFile("Dumbdata.dat")
You use the variable "filein"
in line.
CloseFile( fileout )< It reads & writes correctly but when it hits this command it comes up[File does not exist] How can it say that after it just got thru reading the darn file?
you are trying to close the variable file called "fileout" which isn't open at the time. you need to use closefile (filein)

:) Cheers


Grey Alien(Posted 2006) [#3]
DjBigWorm has hit the nail on the head!


Zooker(Posted 2006) [#4]
Thanks! I think my thumb was on the nail head!