Main Menu

Problem Writing Files

Started by Kman1011, April 25, 2007, 09:09:16 PM

Previous topic - Next topic

Kman1011

I'm having a problem with a program i wrote.

When I try to create a seqential file, It's doesn't get saved for some reason.

When i go to exit the program and quickly look at the files listed in the window where they would get saved, I see two files that read 'Temp_source'... then the files quickly disappear  ???

This is very odd I don't usually have this problem but I've been working on this for 5 hours and still have not figured this out.

here is the subroutine:
SaveMission:
Channel=GetFreeFile()
WriteFile "Mission_#-"+Missionname$+".Mis",Channel
WriteInt Channel,Gamesave
For i=1 To Gamesave
WriteString Channel,Gamefile$(i)
WriteString Channel,gametime$(i)
WriteString Channel,location$(i)
WriteInt Channel,level(i)
Next i
CloseFile Channel
Return


every sub ends with closefile. If I don't use get freefile() then i get an error message 'channel #? already open'

I checked the variables going in and they are OK. Are there certain things you can't put in a filename. Why won't this save. ARG! >:(
Ahh... Another visitor. Stay awhile....STAY FOREVER!!!...MWA-HA-HA-HA

kevin

#1
QuoteWhen I try to create a seqential file, It's doesn't get saved for some reason.

   Have you told it 'where' it should be saved ?  I'd recommend using the absolute path always anyway.

QuoteWhen i go to exit the program and quickly look at the files listed in the window where they would get saved, I see two files that read 'Temp_source'... then the files quickly disappear

  This is the IDE passing the compiler your project info & bundled source code. 

Quoteevery sub ends with closefile. If I don't use get freefile() then i get an error message 'channel #? already open'

   I think you've hit upon an old chestnut with closefile not releasing the file index correctly.   This was only fixed recently i'm not sure in what version though. Prolly in some version 1.63. You'd have to check the history of the update though.

  You could possibly by pass the bug by opening a random access file (then using filepos to read/write it)  and never closing it.  Never tried it but suspect it'd be more trouble than it's worth.


Edit:
  The close file issue was indeed corrected in 1.63

History


  1.63c    14th Jan 2007
* Changes
- Converting File Stream commands to VM2.
* Bugs
- Fixes a Logic issue with Closefile


   But you should really be using 1.63e.   Which is the most current 'update' available.

  Get PlayBasic 1.63e Update

Kman1011

QuoteHave you told it 'where' it should be saved ?  I'd recommend using the absolute path always anyway.

No. It usually saves it in the same folder as the program. Never had a problem before

QuoteThis is the IDE passing the compiler your project info & bundled source code. 

Hmm. Interesting. I thought it was deleteing the files :-X

thanx for the link.  :) I downloaded the patch. I'll  see what happens although in the 'About' in the menu it still says 1.63 not 1.63e. Not sure if this is supposed to be
Ahh... Another visitor. Stay awhile....STAY FOREVER!!!...MWA-HA-HA-HA