showxlib-- XLibraries:openxlib "FileIO.x32"showxlib-- XLibraries:-- "FileIO.x32"set test = new(xtra "FileIO")put the number of xtras-- 1put the name of xtra 1-- "FileIO"showxlib-- XLibraries:-- "FileIO.x32"-- Xtra: FileIOPUT mMessageList(xtra "FileIO")-- "xtra fileio -- CH May96new object me -- create a new child instance-- FILEIO --fileName object me -- return fileName string of the open filestatus object me -- return the error code of the last method callederror object me, int error -- return the error string of the errorsetFilterMask me, string mask -- set the filter mask for dialogsopenFile object me, string fileName, int mode -- opens named file. valid modes: 0=r/w 1=r 2=wcloseFile object me -- close the filedisplayOpen object me -- displays an open dialog and returns the selected fileName to lingodisplaySave object me, string title, string defaultFileName -- displays save dialog and returns selected fileName to lingocreateFile object me, string fileName -- creates a new file called fileNamesetPosition object me, int position -- set the file positiongetPosition object me -- get the file positiongetLength object me -- get the length of the open filewriteChar object me, string theChar -- write a single character (by ASCII code) to the filewriteString object me, string theString -- write a null-terminated string to the filereadChar object me -- read the next character of the file and return it as an ASCII code valuereadLine object me -- read the next line of the file (including the next RETURN) and return as a stringreadFile object me -- read from current position to EOF and return as a stringreadWord object me -- read the next word of the file and return it as a stringreadToken object me, string skip, string break -- read the next token and return it as a stringgetFinderInfo object me -- get the finder info for the open file (Mac Only)setFinderInfo object me, string attributes -- set the finder info for the open file (Mac Only)delete object me -- deletes the open file+ version xtraRef -- display fileIO version and build information in the message window* getOSDirectory -- returns the full path to the Mac System Folder or Windows Directory"put setFilterMask(test,"Amber saved games,*.sav")-- <Void>PUT displayOpen(test)-- "C:\AMBER building\TestGame\SAVEDATA\ugly16.sav"PUT error(test, "C:\AMBER building\TestGame\SAVEDATA\3sounds.sav")-- "Unknown error"PUT error(test,"")-- "Unknown error"put status(test)-- -38put error(test, status(test) )-- "File not open"PUT displaySave(test,"Save game as...","my saved game.sav")-- "C:\AMBER building\TestGame\SAVEDATA\my saved game.sav"PUT version(xtra "FileIO")-- "FileIO 1.0.1 May 31 1996
"--Check this out, like a newly available XCMD!!PUT getOSDirectory()-- "C:\WINDOWS"set test = gVoidshowglobals-- Global Variables --version = "5.0"PUT getOSDirectory()-- "C:\WINDOWS"closexlibPUT getOSDirectory()--ERROR: looks like the xlib has to be open, then this command is available!!-- No instance of FileIO is required!****** to open a game file: *******set test = 0set test = new(xtra "FileIO")setFilterMask(test,"Amber saved games,*.sav")set fPath = displayOpen(test)PUT fPath--check this for errors??put error(test,status( test) )-- "OK"-- "C:\AMBER building\TestGame\SAVEDATA\3sounds.sav"put openFile( test, fPath, 1)-- <Void>put error(test,status( test) )-- "OK"set fileguts = readFile(test)PUT fileguts--LOTS OF STUFF PRINTS..*********** To save file **********If saving with current name (overwriting existing file), then: - make new FileIO child; - use global currentGameFile (holds pathname of most recently opened game-file? CHECK) to openFile( write-only mode; no "append"?? ) - check for errors (e.g. file missing), etc. and respond?? (How is this handled currently?) - writeString( lsStateData ) to the file - closeFile() - if needed (due to errors in existing file?), save new filepath in gCurrentGameFile..If "saving as..", prompting for new file name - ? Can I force path to gSavePath?? (need MOVUTILS.DLL update? CHECK) - set mask for *.SAV - when they specify a name, check (with temporary child object? try to createFile and check the returned error code) to see if it's an existing file; warn 'em? Offer choices ("Do you want to overwrite file 'filename'?" , "OK", ''Cancel")? If they cancel, offer another crack at specifying name..* Warn if overwriting existing file?? Apparently can't prevent it, but how to handle user's choice?