home *** CD-ROM | disk | FTP | other *** search
/ Kiss the Future With Culture / FUTURE.ISO / xtras / fileio.txt < prev    next >
Text File  |  1997-12-10  |  11KB  |  316 lines

  1. FileIO Xtra
  2. Version 1.0.4 - 09dec97 CH
  3.  
  4. FileIO Xtra for Macromedia Director 6.0
  5. =======================================
  6.  
  7. FileIO provides a set of methods allowing users of Macromedia Director 6.0 to
  8. programmatically access files using the Lingo scripting language. The FileIO
  9. Xtra is a scripting Xtra.  The scripting Xtra interface is portable across
  10. all Macromedia products.  Hence the FileIO Xtra may be used with Authorware 4.
  11.  
  12. Using FileIO
  13. ============
  14.  
  15. If automatic opening is desired, place a copy of the FileIO Xtra for your platform
  16. into Application Xtra's folder. If automatic opening is not desired, the Xtra can be 
  17. placed anywhere and opened using Lingo's 'openXLib' command. This applies to 
  18. projector's as well, the Xtra must be placed in an Xtra's folder in the same folder 
  19. as the projector.
  20.  
  21. Each instance of FileIO can reference a single open file. If multiple files are to
  22. be opened simultaneously, a new instance of FileIO is required for each opened file.
  23. A single instance can be used to open multiple files, as long as the file is closed
  24. before a new file is opened. To create a new instance, use the new() method, defined
  25. below. To dispose of an instance, set the instance variable to 0. All methods that
  26. read from or write to the file must be called after the file has been opened using
  27. the openFile() method. If a new file is to be opened using the same instance, the
  28. file must be closed using closeFile(). Files can be opened in three different modes:
  29. Read, Write and Read/Write. When writing to a file, the contents of the file after
  30. the current position are overwritten.
  31.  
  32. Example Lingo
  33.  
  34.  set myFile = new(xtra "fileio")      -- Create an instance of FileIO
  35.  set fileName = displayOpen(myFile)   -- Display Open Dialog and return the fileName
  36.  openFile(myFile, fileName, 1)        -- Open the file
  37.  set theFile = readFile(myFile)       -- Read the file and return a string to Lingo
  38.  closeFile(myFile)                    -- Close the file
  39.  set myFile = 0                       -- Dispose of the instance
  40.  
  41. In this example, we created a new instance and stored it in the variable myFile.
  42. Next, the displayOpen() method is used to display an open dialog to allow a file to
  43. be chosen. The file is returned as a fully-qualified path string to Lingo. The file
  44. is then opened in read only mode, the contents of the file are read, and the file is
  45. closed. Lastly, the instance is disposed of.
  46.  
  47. Known Problems
  48. ==============
  49.  
  50. The createFile() method does not support relative filenames, or the Lingo '@' 
  51. operator in pathnames. This will be fixed in a later version.
  52.  
  53. The displaySave() method does not directly inform Lingo whether a user is 
  54. replacing an existing file. The workaround is to attempt to create the file using
  55. createFile() and check the error code for a "File Already Exists" error.
  56.  
  57. History
  58. =======
  59.  
  60. 09dec97 (v1.0.4)
  61.  
  62. Fixed a problem leading to garbage characters appearing at the ends of lines, 
  63. or possibly crash. 
  64.  
  65. 18apr97 (v1.0.2)
  66.  
  67. Fixed parenting problem with displaySave() and displayOpen() methods.
  68. Added support for Authorware.
  69.  
  70. 27may96 (v1.0.1)
  71.  
  72. Added support for double-byte character sets.
  73. Added version() method to report FileIO Xtra version information. 
  74. Added getOSDir() to return a full path to the Windows Directory/System Folder.
  75.  
  76. 15mar96 (v1.0.0 Beta)
  77.  
  78. First public release.
  79.  
  80. Method Reference
  81. ================
  82.  
  83. The first line of each definition contains the method name, a list of parameters and
  84. thier value types. The internal name of the FileIO Xtra is "fileio". This name is
  85. used whenever referencing the xtra using the form 'xtra "fileio"'.
  86.  
  87. Note that while Director and projector's can use net-based files by supplying a URL
  88. for a filename, the FileIO Xtra cannot. It is limited to accessesing files available
  89. via filesystems mounted on the local system.
  90.  
  91. New methods will appear at the bottom of this list.
  92.  
  93. ---
  94.  
  95. mMessageList( xtra reference )
  96.  
  97. Returns a list of methods and parameters, as well as a brief explanation of each.
  98.  
  99. ---
  100.  
  101. new( xtra reference )
  102.  
  103. This is called to create a new instance of FileIO. The Xtra can be referenced by name
  104. or number. It returns an instance variable used to reference the instance.
  105.  
  106. ---
  107.  
  108. fileName( instance )
  109.  
  110. Returns the fileName string of the current open file.  The file must be open use this
  111. method.
  112.  
  113. ---
  114.  
  115. status( instance )
  116.  
  117. Returns the error code returned by the last method called. The value is returned as
  118. an integer. 
  119.  
  120. ---
  121.  
  122. error( instance, int error )
  123.  
  124. Returns a readable error string. A numeric error code is passed in as the
  125. second argument. The errors returned can be any of the following:
  126.  
  127. "OK"
  128. "Memory allocation failure"
  129. "File directory full"
  130. "Volume full"
  131. "Volume not found"
  132. "I/O Error"
  133. "Bad file name"
  134. "File not open"
  135. "Too many files open"
  136. "File not found"
  137. "No such drive"
  138. "No disk in drive"
  139. "Directory not found"
  140. "Instance has an open file"
  141. "File already exists"
  142. "File is opened read-only"
  143. "File is opened write-only"
  144. "Unknown error"
  145.  
  146. ---
  147.  
  148. setFilterMask( instance, string mask )
  149.  
  150. Sets the filter mask used by calls to displayOpen() and displaySave(). The filter
  151. mask determines what files to show when displaying an Open or Save dialog. The second
  152. parameter is a string representing the filter mask to set. On Windows, this is a
  153. comma seperated string of file types and associated extensions (e.g. "All
  154. Files,*.*,Text Files,*.TXT"), and a string of types on the Macintosh (e.g.
  155. "TEXTPICT"). On Windows, the filter mask string is limited to 256 characters. On the
  156. Macintosh, you are limited to four four-character types.  When a new instance of
  157. FileIO is created, the filter masks defaults to all files. To reset the filter mask to
  158. display all files after it has been set, just pass in an empty string (e.g.
  159. setFilterMask(me, "")).
  160.  
  161. ---
  162.  
  163. openFile( instance, string fileName, int openMode )
  164.  
  165. Opens the named file. This call must be used before any read/write operations can
  166. take place. The filename can be either a fully-qualified path and filename, or a
  167. relative filename. The Lingo '@' pathname operator is supported. The openMode
  168. parameter specifies whether to open the file in Read, Write or ReadWrite mode. Valid
  169. Flags are: 0 Read/Write, 1 Read, 2 Write.
  170.  
  171. ---
  172.  
  173. closeFile( instance )
  174.  
  175. Closes a file that has been previously opened using the openFile() method.
  176.  
  177. ---
  178.  
  179. displayOpen( instance )
  180.  
  181. Displays a platform specific Open dialog allowing a user to specify a file. Returns a
  182. fully-qualified path and fileName to Lingo. The setFilterMask() method can be used to
  183. control what file types are displayed in the dialog.
  184.  
  185. ---
  186.  
  187. displaySave( instance, string title, string defaultFileName )
  188.  
  189. Displays a platform specific Save dialog allowing a user to specify a file. Returns a
  190. fully-qualified path and fileName to Lingo. The setFilterMask() method can be used to
  191. control what file types are displayed in the dialog. The string and defaultFileName 
  192. parameters allow you to specifiy a default filename to be displayed, as well as title
  193. text for the save dialog. 
  194.  
  195. ---
  196.  
  197. createFile( instance, string fileName )
  198.  
  199. Creates a file. The fileName must be either a fileName to be created in the current
  200. directory, or a fully-qualified path and fileName. The Lingo '@' pathname operator
  201. and relative paths are not supported. After creating the new file, the file must be
  202. opened before it can be written to.
  203.  
  204. ---
  205.  
  206. setPosition( instance, position )
  207.  
  208. Sets the file position of the current open file. The file must be open to use this 
  209. method.
  210.  
  211. ---
  212.  
  213. getPosition( instance )
  214.  
  215. Gets the file position of the current open file. Returned as an integer. The file
  216. must be open to use this method. 
  217.  
  218. ---
  219.  
  220. getLength( instance )
  221.  
  222. Gets the length of the currently opened file. Returned as an integer. The file must
  223. be open use this method. The value returned is the length of the file in bytes. 
  224.  
  225. ---
  226.  
  227. writeChar( instance, string theChar )
  228.  
  229. Writes a single character to the file at the current position. The file must be open
  230. in write or read/write mode to use this method.
  231.  
  232. ---
  233.  
  234. writeString( instance, string theString )
  235.  
  236. Writes a string to the file at the current position. The file must be open in write
  237. or read/write mode to use this method.
  238.  
  239. ---
  240.  
  241. readChar( instance )
  242.  
  243. Reads the character (either single or double-byte) at the current position and then 
  244. increments the position. The character is returned to Lingo as a string. The file must 
  245. be open in read or read/write mode to use this method. 
  246.  
  247. ---
  248.  
  249. readLine( instance )
  250.  
  251. Reads from the current position up to and including the next CR, increments the
  252. position, and returns the string to Lingo.  The file must be open in read or
  253. read/write mode to use this method. 
  254.  
  255. ---
  256.  
  257. readFile( instance )
  258.  
  259. Reads from the current position to the end of the file and returns the file to Lingo
  260. as a string.  The file must be open in read or read/write mode to use this method.
  261.  
  262. ---
  263.  
  264. readWord( instance )
  265.  
  266. Reads the next word starting at the current position.  The file must be open in read
  267. or read/write mode to use this method. 
  268.  
  269. ---
  270.  
  271. readToken( instance, string skipChar, string breakChar )
  272.  
  273. Reads the next 'token' starting at the current position. Characters matching the
  274. skipChar parameter are "skipped" and the file is read until breakChar is encountered.
  275. The file must be open in read or read/write mode to use this method. This method will
  276. read double-byte tokens as long as the skip and break are single-byte characters. It
  277. will not detect double-byte skip or break characters.
  278.  
  279. ---
  280.  
  281. getFinderInfo( instance )
  282.  
  283. Returns the Type and Creator of the current file as a string. This method does
  284. nothing when used under Windows.  The file must be open to use this method.
  285.  
  286. ---
  287.  
  288. setFinderInfo( instance, string typeAndCreator )
  289.  
  290. Sets the Type and Creator of the current file. The string takes the form of a space
  291. seperated set of TYPE and CREATOR codes (e.g. "TEXT TTXT"). This method does nothing
  292. when used under Windows.  The file must be open to use this method.
  293.  
  294. ---
  295.  
  296. delete( instance )
  297.  
  298. Deletes the currently opened file.  The file must be open use this method.
  299.  
  300. ---
  301.  
  302. version( xtraRef )
  303.  
  304. Returns FileIO version and build information. Useful when filing 
  305. bug reports, determining installed version while authoring, etc. No practical use beyond this.
  306.  
  307. ---
  308.  
  309. getOSDir( )
  310.  
  311. Global method that returns the full path to either the Windows directory, or the System Folder 
  312. depending on which OS is currently being used. Does not require a child instance or
  313. Xtra reference to call.
  314.  
  315. ---
  316.