home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC/CD Gamer UK 39
/
PCGAMER39.bin
/
games
/
amber
/
amberhub.dxr
/
00037_Field_37.txt
< prev
next >
Wrap
Text File
|
1996-11-08
|
5KB
|
136 lines
showxlib
-- XLibraries:
openxlib "FileIO.x32"
showxlib
-- XLibraries:
-- "FileIO.x32"
set test = new(xtra "FileIO")
put the number of xtras
-- 1
put the name of xtra 1
-- "FileIO"
showxlib
-- XLibraries:
-- "FileIO.x32"
-- Xtra: FileIO
PUT mMessageList(xtra "FileIO")
-- "xtra fileio -- CH May96
new object me -- create a new child instance
-- FILEIO --
fileName object me -- return fileName string of the open file
status object me -- return the error code of the last method called
error object me, int error -- return the error string of the error
setFilterMask me, string mask -- set the filter mask for dialogs
openFile object me, string fileName, int mode -- opens named file. valid modes: 0=r/w 1=r 2=w
closeFile object me -- close the file
displayOpen object me -- displays an open dialog and returns the selected fileName to lingo
displaySave object me, string title, string defaultFileName -- displays save dialog and returns selected fileName to lingo
createFile object me, string fileName -- creates a new file called fileName
setPosition object me, int position -- set the file position
getPosition object me -- get the file position
getLength object me -- get the length of the open file
writeChar object me, string theChar -- write a single character (by ASCII code) to the file
writeString object me, string theString -- write a null-terminated string to the file
readChar object me -- read the next character of the file and return it as an ASCII code value
readLine object me -- read the next line of the file (including the next RETURN) and return as a string
readFile object me -- read from current position to EOF and return as a string
readWord object me -- read the next word of the file and return it as a string
readToken object me, string skip, string break -- read the next token and return it as a string
getFinderInfo 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)
-- -38
put 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 = gVoid
showglobals
-- Global Variables --
version = "5.0"
PUT getOSDirectory()
-- "C:\WINDOWS"
closexlib
PUT 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 = 0
set 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?