|
||
Inside Technique : Sokoban Level Designer : Client Data Access with HTML Applications : FileSaveAs function The last function we will be looking at in this library is the FileSaveAs function. This tiny function introduces no new concepts, it is just a combination of the FileNew and FileSave functions :
//Check if there is a file to save
if(DataFile==''){
alert('No Data File currently loaded');
return;
}
//Save the path of the current file
SaveDataURL=TDC1.dataURL;
//Call FileNew to create the data file
FileNew();
//Check if FileNew has bombed
if(TDC1.dataURL==SaveDataURL)
return;
//Save to new file
newURL=TDC1.dataURL;
TDC1.dataURL=SaveDataURL;
TDC1.Reset();
FileSave();
TDC1.dataURL=newURL;
TDC1.Reset();
The only thing of note in this function is that it checks whether the FileNew function has bombed (either because of a user Cancel or some other error) by comparing the values of TDC1.dataURL before and after the call to the FileNew function. If the values are the same, it means an error has occured, so the function quietly returns, otherwise it sets the dataURL back to it's original value , calls the FileSave function, the sets the dataURL to it's new value again. On the last page, you can download complete the Sokoban Package for play on your machine. This package includes the Sokoban Game and Level Designer. Page 1:Sokoban Level Designer : Client Data Access with HTML Applications © 1997-2000 InsideDHTML.com, LLC. All rights reserved. |