ID:264945
 
Problem #1:

The code pasted below is a stand-alone snippet found in the DM reference under the topic "Export proc (client)". Whenever I run the dmb and use the save() verb, upon the FIRST execution I get the following error which ultimately causes a proc crash:

runtime error: bad output
proc name: save (/mob/verb/save)
usr: Lethal Dragon (/mob)
src: Lethal Dragon (/mob)
call stack:
Lethal Dragon (/mob): save()

The second, third time, etc, do not cause problems. The file saves as 0.sav inside my KeyInfo folder as a client side save, but not until the SECOND execution of the verb.

Code:
mob/verb/save()
var/savefile/F = new()
F << usr //write the player's mob
usr.client.Export(F)

client/New()
var/client_file = Import()
if(client_file)
var/savefile/F = new(client_file) //open it as a savefile
F >> usr //read the player's mob
return ..()


Problem #2:

This could very easily be related to Problem #1. In my code file I've written three procedures (as mob verbs). They save, load and delete the client side save. EACH of them work without error, except if I trigger the issue. I hit save, the file saves in my KeyInfo folder. I then hit delete, the file is removed from the KeyInfo folder and from memory. ***HOWEVER*** if I save the file, then either load it or try to overwrite it prior to deleting it, the file becomes "locked". By this I mean the file cannot be deleted at runtime nor can it be overwritten because it is being used by the program, apparently. So it is the case that the file, if altered or loaded, cannot be deleted until after closing out of the dmb file. Very bizarre.

Code:
        TESTsave()
if( !client.Import() )
var/savefile/SAVE = new()
SAVE = new() // Seems redundant but, if not included, this proc crashes upon its FIRST execution
SAVE["name"] << "Fish"
client.Export( SAVE )
TESTload()
var/savefile/SAVE = new( client.Import() )
var/HERE = SAVE["name"]
world << HERE
TESTdeletesave()
client.Export()
Ok, I'm no longer getting the "bad output" proc crash. But problem #2 is still occurring, where the file cannot be deleted at runtime. Any help would be greatly appreciated. :)

Edit: Basically I am looking for any means to overwrite a client-side save at runtime. If any code could be supplied for this purpose, I'd be grateful. So far I've been able to create the save file with saved data, but I am unable to overwrite it in any way.