Main Menu

Save Problem

Started by darkx, October 18, 2009, 07:17:53 PM

Previous topic - Next topic

darkx

I seem to be having a problem saving and loading in my program. When I save once and load it seems to work fine however if I save twice and load a different file it seems to crash my program if any one could help I would greatly appreciate it. When loading make sure you load the SWC the txt is just for reading purposes. If you need an answer please ask.

kevin

#1
  When we save information and reload, it's important the loading state be re-initialized,  so if data is currently in memory, we flush all old resources out prior to loading.

darkx

#2
I don't think that's the problem



PlayBASIC Code: [Select]
If GetSpriteStatus(tempsprite)=1
DeleteSprite tempsprite
EndIf

DeleteSprite SW_sprite.index
SW_sprite=null





Next

For Each SW_img()
If SW_img.shapea=1
DeleteShape SW_img.shapenum
EndIf
DeleteSprite SW_img.imgsprite
DeleteImage SW_img.imgnum
DeleteImage SW_img.clone
SW_img=null
Next




was put in front of the load function.

markel422

I think I know what you are talking about and I have the same problem...

When you come to save your program as usually for the first time you go to "Save As..." then after you work on the program some more you decide to save the program once again by going to just "Save" and you tend to realize that it was put in a different file when it came to you (probably...) loading up another program and for some reason your program gets saved into that same section of files and you end up getting different code or files under your file you meant to only save on its own.

Don't know why that happens though...but the way I tackled this was to keep choosing "Save As..." and Browse back to that file I want to originally Save it in.

darkx

I'm not sure that I exactly follow you...There is no save-as option as pressing save always makes a new file on my program. It also won't allow you to save it under the same file name as another file. The problem seems to be saving after loading a file. The file it creates causes the program to crash. However if I don't load a file and create something and save it for the first time the file seems to load fine.

kevin


He's talking about the ide.

There's a things that seems like errors to me, but it's hard tell without going through it.



  If FileExist(result$)=0
   WriteFile result$+".SWC",1


darkx

QuoteHe's talking about the ide.

There's a things that seems like errors to me, but it's hard tell without going through it.


Code:


  If FileExist(result$)=0
   WriteFile result$+".SWC",1

That was intentional it makes sure you don't overwrite existing file, and forces you to make a new file where the name isn't already taken.

kevin

#7
  I know what it's meant to do, but that's not what it's doing.. 

  For example  if  Result$ = "Bill.txt"  .  So the compare is checking if the file Bill.txt exists..  However on the next line, if the file doesn't exist,  your creating the file  via Result$+".SWC", so the filename for the output file is actually Bill.txt.SWC

so if you save the project a second time, it'll fail... 



darkx

#8
I've added this line in to my code If FileExist(result$+".SWC")=0 however it still seems to mysteriously crash. And the .txt file isn't what's really being read their just there to convert the save file in to human readable format. I just don't get whats wrong...after comparing the save file they look the same. Except the order of the variables are listed backwards, I'm not sure if it's the problem but it shouldn't matter because the bolded numbers as show below are the same.

Quote3
3

3
SWmedia/sl2.PNG
206
112
64
64
0

2
SWmedia/floor.PNG
207
44
44
64
0

1
SWmedia/cursor.png
10
10
10
10
0

3
3
0
3
0
0
0
0
0
0
294
138
50
2
0
3
0
0
0
0
0
0
406
286
50
3
0
3
0
0
0
0
0
0
161
276
50

Quote3
3

1
SWmedia/cursor.png
10
10
10
10
0

2
SWmedia/floor.PNG
207
44
44
64
0

3
SWmedia/sl2.PNG
206
112
64
64
0

3
3
0
3
0
0
0
0
0
0
161
276
50
2
0
3
0
0
0
0
0
0
406
286
50
3
0
3
0
0
0
0
0
0
294
138
50

darkx

Ah ha! I think I found the culprit I'll post the results once I test my theory.

darkx

#10
Nope that wasn't it. The problem even happens if I save twice and load the second save without loading a file first..

kevin


If i save the same file twice, it displays the unable to save file message. 

darkx

I've fixed it by tinkering around the code...Although I'm not sure what exactly I did, but thank you for your time Kevin.