News:

PlayBASIC2DLL V0.99 Revision I Commercial Edition released! - Convert PlayBASIC programs to super fast Machine Code. 

Main Menu

File won't write

Started by Kman1011, May 29, 2007, 09:33:14 PM

Previous topic - Next topic

Kman1011

I'm trying to write a sub that will store data for gamesaves. But for some reason the file will not write.
I get the error message "Attempting to read beyond file"

but the writefile routine clearly shows the file being written

Not sure I understand why this is not working.

; PROJECT : Writereadmission
; AUTHOR  : Kman
; CREATED : 4/28/2007
; EDITED  : 5/29/2007
; ---------------------------------------------------------------------
Dim name$(10)
Dim mission_Score(10)
Dim GameSave(10)
Dim gamefile$(10,25)
Dim gametime$(10,25)
Dim location$(10,25)
Dim level(10,25)
name$(1)="Kent"
gamesave(1)=1
maxmission=1
mission_Score(1)=2300
Gamefile$(1,1)="BlackIce"
gametime$(1,1)="00:00:12"
location$(1,1)="level 1,3"
level(1,1)=1

SaveMission:
WriteFile "Missions.Mis",1
WriteInt 1,Maxmission
Print "# of missions"+Str$(maxmission)
For mis=1 To Maxmission
WriteString 1,name$(mis)
WriteInt 1,mission_Score(mis)
WriteByte 1,GameSave(mis)
Print name$(mis)
Print mission_score(mis)
Print gamesave(mis)
Sync
WaitKey
For g=1 To gamesave(mis)
WriteString 1,Gamefile$(mis,g)
WriteString 1,gametime$(mis,g);
WriteString 1,location$(mis,g)
WriteInt 1,level(mis,g)
Next g
Next mis
CloseFile 1
WaitNoKey

OpenFile "Missions.Mis",1
Print "MISSION FILE:"
Maxmission=ReadInt(1)
Print "Total Missions: "+Str$(Maxmission)
For mis=1 To Maxmission
name$(mis)=Readstring$(1)
mission_Score(mis)=Readint(1)
gamesave(mis)=Readbyte(1)

Print "=============================="
Ink RGB(255, 128, 64)
Print "Mission Name: "+name$(mis)
Print "Mission Score: "+Str$(Mission_Score(mis))
Print "Total Saves: "+Str$(GameSave(mis))

For g=1 To Gamesave(mis)
Gamefile$(mis,g)=ReadString$(1)
gametime$(mis,g)=ReadString$(1)
location$(mis,g)=ReadString$(1)
level(mis,g)=ReadInt(1)
Print "----------------------------"
Ink RGB(255, 255, 0)
Print "Game Name: "+Gamefile$(mis,g)
Print "Game Time: "+gametime$(mis,g)
Print "Game Location: "+location$(mis,g)
Print "Game Sector: "+Str$(level(mis,g))
Next g
Next mis
CloseFile 1
waitnokey
Sync
WaitKey
End



If there is a glitch somebody sees. let me know. Working with these files can be extremely frustrating.  :'( Had three problems with them already. Figured out one of them.

S.O.S.
Ahh... Another visitor. Stay awhile....STAY FOREVER!!!...MWA-HA-HA-HA

Alex

works for me. im useing v. 1.63e

kevin

#2
 The problem might be related to this (login required)

Kman1011

Sounds like a bug then and i'm not alone

    I click on the About... in the menu bar. It says v. 1.63. There is no 'e' after the version number. I was certain I had downloaded the latest update.

I'll try something different.
Ahh... Another visitor. Stay awhile....STAY FOREVER!!!...MWA-HA-HA-HA