home *** CD-ROM | disk | FTP | other *** search
/ PC/CD Gamer UK 39 / PCGAMER39.bin / games / amber / amberhub.dxr / 00037_Field_37.txt < prev    next >
Text File  |  1996-11-08  |  5KB  |  136 lines

  1. showxlib
  2. -- XLibraries:
  3.  
  4. openxlib "FileIO.x32"
  5. showxlib
  6. -- XLibraries:
  7. -- "FileIO.x32"
  8.  
  9. set test = new(xtra "FileIO")
  10.  
  11. put the number of xtras
  12. -- 1
  13. put the name of xtra 1
  14. -- "FileIO"
  15.  
  16. showxlib
  17. -- XLibraries:
  18. -- "FileIO.x32"
  19. --   Xtra: FileIO
  20.  
  21. PUT mMessageList(xtra "FileIO")
  22. -- "xtra fileio -- CH May96
  23. new object me -- create a new child instance
  24. -- FILEIO --
  25. fileName object me -- return fileName string of the open file
  26. status object me -- return the error code of the last method called
  27. error object me, int error -- return the error string of the error
  28. setFilterMask me, string mask -- set the filter mask for dialogs
  29. openFile object me, string fileName, int mode -- opens named file. valid modes: 0=r/w 1=r 2=w
  30. closeFile object me -- close the file
  31. displayOpen object me -- displays an open dialog and returns the selected fileName to lingo
  32. displaySave object me, string title, string defaultFileName -- displays save dialog and returns selected fileName to lingo
  33. createFile object me, string fileName -- creates a new file called fileName
  34. setPosition object me, int position -- set the file position
  35. getPosition object me -- get the file position
  36. getLength object me -- get the length of the open file
  37. writeChar object me, string theChar -- write a single character (by ASCII code) to the file
  38. writeString object me, string theString -- write a null-terminated string to the file
  39. readChar object me -- read the next character of the file and return it as an ASCII code value
  40. readLine object me -- read the next line of the file (including the next RETURN) and return as a string
  41. readFile object me -- read from current position to EOF and return as a string
  42. readWord object me -- read the next word of the file and return it as a string
  43. readToken object me, string skip, string break -- read the next token and return it as a string
  44. getFinderInfo object me -- get the finder info for the open file (Mac Only)
  45. setFinderInfo object me, string attributes -- set the finder info for the open file (Mac Only)
  46. delete object me -- deletes the open file
  47. + version xtraRef -- display fileIO version and build information in the message window
  48. * getOSDirectory -- returns the full path to the Mac System Folder or Windows Directory
  49. "
  50.  
  51. put setFilterMask(test,"Amber saved games,*.sav")
  52. -- <Void>
  53. PUT displayOpen(test)
  54. -- "C:\AMBER building\TestGame\SAVEDATA\ugly16.sav"
  55.  
  56. PUT error(test, "C:\AMBER building\TestGame\SAVEDATA\3sounds.sav")
  57. -- "Unknown error"
  58. PUT error(test,"")
  59. -- "Unknown error"
  60.  
  61. put status(test)
  62. -- -38
  63. put error(test, status(test) )
  64. -- "File not open"
  65.  
  66.  
  67. PUT displaySave(test,"Save game as...","my saved game.sav")
  68. -- "C:\AMBER building\TestGame\SAVEDATA\my saved game.sav"
  69. PUT version(xtra "FileIO")
  70. -- "FileIO 1.0.1 May 31 1996
  71. "
  72.  
  73. --Check this out, like a newly available XCMD!!
  74. PUT getOSDirectory()
  75. -- "C:\WINDOWS"
  76. set test = gVoid
  77. showglobals
  78.  
  79. -- Global Variables --
  80. version = "5.0"
  81. PUT getOSDirectory()
  82. -- "C:\WINDOWS"
  83. closexlib
  84.  
  85. PUT getOSDirectory()
  86. --ERROR:  looks like the xlib has to be open, then this command is available!!
  87. --  No instance of FileIO is required!
  88.  
  89.  
  90. ******  to open a game file: *******
  91.  
  92. set test = 0
  93. set test = new(xtra "FileIO")
  94.  
  95. setFilterMask(test,"Amber saved games,*.sav")
  96. set fPath = displayOpen(test)
  97.  
  98. PUT fPath
  99. --check this for errors??
  100. put error(test,status( test) )
  101. -- "OK"
  102.  
  103. -- "C:\AMBER building\TestGame\SAVEDATA\3sounds.sav"
  104. put openFile( test, fPath, 1)
  105. -- <Void>
  106. put error(test,status( test) )
  107. -- "OK"
  108.  
  109.  
  110. set fileguts = readFile(test)
  111. PUT fileguts
  112. --LOTS OF STUFF PRINTS..
  113.  
  114.  
  115. *********** To save file **********
  116.  
  117. If saving with current name (overwriting existing file), then: 
  118.   - make new  FileIO child;
  119.   - use global currentGameFile (holds pathname of most recently opened game-file? CHECK)
  120.         to openFile( write-only mode; no "append"?? )
  121.   - check for errors (e.g. file missing), etc. and respond?? (How is this handled currently?)
  122.   - writeString( lsStateData ) to the file
  123.   - closeFile()
  124.   - if needed (due to errors in existing file?), save new filepath in gCurrentGameFile..
  125.  
  126. If "saving as..", prompting for new file name
  127.   - ? Can I force path to gSavePath?? (need MOVUTILS.DLL update? CHECK)
  128.   - set mask for *.SAV
  129.   - when they specify a name, check (with temporary child object? try to createFile and check 
  130.        the returned error code) to see if it's an existing file;
  131.        warn 'em? Offer choices ("Do you want to overwrite file 'filename'?" , "OK",  ''Cancel")? If
  132.        they cancel, offer another crack at specifying name..
  133.  
  134. * Warn if overwriting existing file?? Apparently can't prevent it, but how to handle user's choice?
  135.  
  136.