home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 200-299 / ff257.lzh / FileIO / FileIO.DOC < prev    next >
Text File  |  1989-10-19  |  87KB  |  1,827 lines

  1. FileIO Requester
  2. User and Programmer Manual
  3. From the Amiga Programmer's Suite Book 1, by RJ Mical
  4. Copyright (C) 1987, Robert J. Mical
  5.  
  6. Additional notes concerning the requester library have been added by
  7. Jeff Glatt who converted the original C into an assembly language library.
  8.  
  9. This document describes the FileIO Requester library, both for users of
  10. the requester and for programmers who will utilize the library.
  11. The main sections of this document are:
  12.  
  13.    o  FROM THE USER'S POINT OF VIEW
  14.  
  15.    o  PROGRAMMER'S REFERENCE
  16.  
  17.    o  DEMO PROGRAM NOTES
  18.  
  19.    o  TECHNICAL REFERENCE
  20.  
  21.    o  USING THE AMIGA PROGRAMMER'S SUITE
  22.  
  23.    o  APPENDIX A:  FileIO Library Function Calls
  24.  
  25.  
  26.  
  27. ============================================================================
  28. === FROM THE USER'S POINT OF VIEW ==========================================
  29. ============================================================================
  30.  
  31. This section presents the FileIO Requester from the user's point of view.  
  32. This is a example of the sort of documentation that might be supplied to the
  33. end user of this FileIO Requester. Simply clip from here to the Programmer's
  34. section, and include this as a chapter in the user manual.
  35.  
  36.  
  37.  
  38. === The FileIO Requester ========================================
  39.  
  40.   This program employs a file requester based upon R.J. Mical's ProSuite
  41. unit, though this library implementation has been modified extensively.
  42.   The FileIO Requester allows you an easy way to select which file you want 
  43. to use for input or output.  The following describes how you go about using 
  44. the FileIO Requester.
  45.  
  46. The FileIO Requester consists of several parts:  
  47.  
  48.    o  the "Select a Name" list which allows you to choose a file name
  49.       simply by scrolling through a list of names until you find the one
  50.       you want, pointing at the name and clicking the left mouse button
  51.  
  52.    o  the OK! gadget which you use to acknowledge that the name you've 
  53.       chosen is the one you wanted
  54.  
  55.    o  3 string gadgets which allow you to type in the name directly rather
  56.       than using the "Select a Name" gadgets to find the file you want 
  57.  
  58.    o  a NEXT DISK gadget which allows you to examine one disk after another 
  59.  
  60.    o  the CANCEL gadget, which you use when you've decided that you don't
  61.       want to select a file after all
  62.  
  63. The "Select a Name" list presents you with a list of file names in the 
  64. current drawer. You use the mouse to scan easily through the list and select
  65. one of the filenames simply by pointing at it and clicking.  
  66.  
  67. The "Select a Name" feature consists of:
  68.  
  69.    o  a box of where some of the list of file names are displayed
  70.  
  71.    o  a slider which lets you scan quickly through the list of files
  72.  
  73.    o  an up gadget and a down gadget which allow you to move through the
  74.       list one filename at a time
  75.  
  76.  
  77. There are 3 types of entries in the list of file names.
  78.  
  79. At the top of the list are the file names that you can choose.  These names
  80. are listed in alphabetical order (case insensitive).  
  81.  
  82. At the bottom of the list there are special entries which allow you to move 
  83. around through the drawers of a disk, much like you move around through 
  84. drawers on the Workbench display.  
  85.  
  86. The entries that start with the ">>>>" characters allow you to "open" a 
  87. drawer and examine the names of the files in that drawer.  For example, when
  88. examining a Workbench disk, at the bottom of the list you would find an
  89. entry that looked like ">>>> Demos" which means that you can go into the
  90. drawer named "Demos".  If you selected ">>>> Demos" you would see, after a
  91. short pause, a new list of file names:  the names of the files that are in
  92. the "Demos" drawer.  
  93.  
  94. In the "Demos" drawer you would also find a special entry,
  95. "<<<< PRIOR DRAWER".  If you select this entry, you will move back to 
  96. the drawer that contained your current drawer.  
  97.  
  98. An alternate way to change drawers is to type the name of the drawer you 
  99. want in the string gadget labeled "Drawer". It is located beneath the 
  100. filename list.  You select the gadget, type in the name, and hit return.
  101. If you type the name of a drawer which does not exist, the FileIO will send
  102. you back to the root directory of that disk. The length of the string that
  103. you type into the drawer gadget is limited to 132 characters. Since AmigaDOS
  104. limits the length of all file, drawer, and disk names to 30 characters, this
  105. means that you can safely nest drawers (one inside of another) up to four
  106. drawers deep. Beyond that, you should make sure that your drawer names are
  107. less than 30 chars each. The FileIO will not allow you to go any deeper after
  108. the drawer gadget has 132 chars in it.
  109.  
  110. Once you have a list of file names to choose from in the file name box, 
  111. there's a slider gadget to help you scroll around through the names. The
  112. slider is to the right of the file names.  It has a knob which you move to
  113. scroll through the names.  The knob will be different sizes depending on the
  114. number of names in the file list.  If the knob is small, this means that you 
  115. can see only a small number of the total file names. The smaller the knob,
  116. the more names there are to see.  On the other hand, if you can see all the
  117. names in the list, the knob will fill up the entire slider and you won't be
  118. able to move it.
  119.  
  120. To view the file names, you "grab" the slider's knob and move it up and down.  
  121. You grab the knob by pointing at it and pressing and HOLDING the left mouse
  122. button.  When you have grabbed the knob, you can move the pointer and scan
  123. quickly through the list of file names.
  124.  
  125. Also, you can view the list of names one page at a time by clicking to either
  126. side (but not on) the slider's knob.  If you want fine control of your
  127. movement through the file list, the up and down arrows let you adjust the
  128. list of names one name at a time. If you hold the mouse button down while on
  129. top of either arrow, the filenames will scroll in that direction. When you
  130. release the button, scrolling stops, but if instead you move off the arrow
  131. before releasing, the scrolling continues. Auto-scroll will continue until
  132. you click on a scrolling filename, or until the end of the list is reached.
  133.  
  134. Once you have found the file name that you want to choose, you select it by
  135. pointing at it and clicking.  When you do this, the name will be highlighted
  136. and it will appear in a box labeled "Name" beneath the list.  When you've
  137. decided that this is really the name you wanted to choose, click on the OK!
  138. gadget.  Another way to tell the program that you're sure you want to select
  139. a certain file name is by double-clicking on the file name in the same way
  140. that you double-click on a Workbench icon.  Double-clicking is exactly the
  141. same as selecting a name and then OK!
  142.  
  143. If you don't want to use the "Select a Name" feature, you can select a name
  144. by clicking on the string gadget labeled "Name", typing the desired filename, 
  145. and then hitting return or clicking on the OK! gadget.  Hitting return after
  146. typing the name you want is the same as selecting OK! You can select and
  147. type into the string gadgets at any time. You don't have to wait for the
  148. wait pointer to change before you hit return! If you type in the name of a
  149. disk that is not mounted, and then refuse to insert it into the drive when
  150. AmigaDOS asks you for it, the FileIO switches to another disk that is
  151. mounted (if another floppy exists).
  152.  
  153. To view the files of a different disk, select the NEXT DISK gadget. When you
  154. do, the name of the next disk is displayed in the Disk string gadget and the
  155. disk is then searched.  If this disk isn't the one you wanted, you can press
  156. NEXT DISK again even though you may be seeing the wait pointer.  You can
  157. press NEXT DISK quickly as many times as you want until you see the name of
  158. the disk you want in the Disk gadget. If you prefer, you can also type the
  159. name of the disk you want directly into the Disk string gadget. If the disk
  160. you want to examine is not in the drive, you may remove the disk that the
  161. requester has last examined (after the light goes out of course), and insert
  162. the desired disk in that drive. Now wait for the requester to automatically
  163. update its display. You should not change disks while the file requester is
  164. drawing the list of filenames. Wait until the requester "settles down" before
  165. removing and inserting disks. After inserting a disk, the requester will
  166. automatically redraw the list.
  167.    Alternately, you may select a new disk by clicking the RIGHT MOUSE button.
  168. The filenames will be replaced by a list of all the mounted volumes (or
  169. devices). The name of the disk that you are currently examining will be
  170. highlighted. You can scroll through this list of disk names using the slider.
  171. When you see the disk name that you would like to examine, click the LEFT
  172. MOUSE button on it. The FileIO will then display the contents of that disk.
  173.  
  174.  You might notice that the ZZZ-cloud wait pointer looks a little different 
  175. from the ones you're used to on the Amiga.  The FileIO Requester's ZZZ-cloud
  176. pointer has a small tab at the top left which allows you to continue 
  177. pointing and making selections even though the ZZZ-cloud is displayed.  
  178. The FileIO Requester's ZZZ-cloud tells you that it's working, but it
  179. doesn't make you wait.
  180.  
  181.   You might notice also that the file names start appearing one by one 
  182. alphabetically in the list.  You can select one of these names even before
  183. all of the names have been added to the list, though this can be a bit
  184. tricky as they move around a lot.  While the list is being built, you can
  185. use the slider to look at what names have already been added. If you see the
  186. name that you want to select, you can stop the building of the file name
  187. list by clicking on a spot inside the requester but outside of all the
  188. gadgets. For instance, if you click above (but not on) the OK! gadget, this
  189. will stop the list from being constructed. Then you can select the name you
  190. want as usual.  To restart the building of the file name list, click on
  191. either the Drawer or Disk string gadget and hit return. You can also stop
  192. the display of filenames temporarily by grabbing and holding the scroll
  193. gadget. When you release, the display will continue.
  194.  
  195.   For some reason, the requester may not be able to open. Maybe another
  196. program is already displaying it. Only one program can be displaying it at a
  197. time. Or perhaps you have used up too much memory. In either case, instead
  198. of a requester, you will see this prompt in the title bar of the window.
  199.  
  200.   Filename >
  201.  
  202.   This will be followed by a cursor and whatever filename you last chose
  203. with the requester. You must now type in the complete name (including the
  204. drive and drawer names) as you would in the CLI. For example,
  205.  
  206.   Extras:BasicDemos/ConvertFD
  207.  
  208.   If the window is not full size, you should move it to the upper left
  209. corner of the monitor display, and resize it to fully open. Then press any
  210. cursor key to redisplay the cursor. If there was no previous filename, then
  211. you will see the ":" current directory sign. Move the cursor past this and
  212. type in the filename that you wish to save or load if it is on the current
  213. disk. Otherwise, you need to type the name of the disk upon which the file
  214. can be found. The disk name goes in front of the ":", and the drawers and
  215. filename go after the ":". (If the file is on the current disk, and in the
  216. current drawer, you only need to type the filename. Otherwise, you must
  217. specify which disk and drawer you really want.) If the filename that is
  218. initially displayed is the one that you want, simply press RETURN.
  219.  
  220.   You can use the cursor keys to move about in the filename, deleting charac-
  221. ters with the delete or backspace keys. Holding the shift key while pressing
  222. the cursor keys will move to the beginning and end of the typed filename.
  223. When you are satisfied with your choice, hit RETURN. Otherwise, hit the
  224. escape key to cancel.
  225.  
  226.   You have the facility to "customize" the requester for each application.
  227. After the requester comes up, the function keys have the following purposes:
  228.  
  229. F1 - Operates the same as selecting the Next Disk gadget.
  230. F2 - Toggles between using the volume name or the device name of the floppy.
  231.      For example, if you place your WorkBench disk in the internal drive
  232.      and you are using volume names, "WorkBench 1.3:" will appear for the
  233.      Disk name. If using device names, "DF0:" will appear instead.
  234. F3 - Any filename that ends in ".info" will not be displayed. To disable
  235.      this feature, select F3 again.
  236. F4 - Only displays filenames that end with a phrase that you provide.
  237.      You will be prompted to enter a string in the title bar of the window.
  238.      If for example, you typed .library, then the requester would display
  239.      all drawers, but only those files that end with .library. The word
  240.      need not be an extension. You could also specify that only files that
  241.      end with the word, picture, be displayed. To disable this feature,
  242.      select F4 again. The program that you are using must support this
  243.      feature for it to work. If the program doesn't support it, F4 will do
  244.      nothing.
  245. F5 - This toggles ON/OFF the facility for double-clicking on a filename to
  246.      select it as your final choise. If OFF, you must click on the
  247.      filename, and then select OK! before the requester will accept your
  248.      choise as final. Otherwise, 2 quick clicks will be the same thing.
  249. F6 - This will cause the requester not to initially reconstruct the filename
  250.      list on subsequent uses. The advantage is that the next time the req-
  251.      uester comes up, the names will appear immediately. The disadvantage is
  252.      that if you save a file, it will not appear in the list until you turn
  253.      this feature back on (momentarily anyway). Turn it on/off by pressing F6.
  254. F7 - WorkBench matching ON/OFF. If ON, this only displays those names that
  255.      end in .info (just like WorkBench does). Also, a prompt asks you whether
  256.      you want only those names that are TOOLS, PROJECTS, or any kind. An example
  257.      of a TOOL is a program that you can run, like NotePad. An example of a
  258.      PROJECT is a data file, like a note you might write using NotePad.
  259.      The names of disks are never displayed in the filename list.
  260. F8 - Not implemented at this point.
  261. F9 - Same as the CANCEL gadget.
  262. F10 - Same as the OK! gadget.
  263.  
  264.  When you customize the requester, it only affects that one application, so
  265. different programs can have different "customized" requesters.
  266.  
  267.  
  268.  
  269. ============================================================================
  270. === PROGRAMMER'S REFERENCE =================================================
  271. ============================================================================
  272.  
  273. This section is for the programmer who wants to use the FileIO Requester 
  274. library routines in her or his program.
  275.  
  276. The Workbench names for DOS objects have been used in the FileIO Requester, 
  277. and are used throughout this document for simplicity.  For your reference, 
  278. a directory is referred to as a "drawer" and volumes, or DOS filesystem 
  279. devices, are referred to as "disks".
  280.  
  281. These are the subsections of this section:
  282.  
  283.    o  Basic Operation
  284.  
  285.    o  Multiple FileIO Structures
  286.  
  287.    o  Workbench-style Filename Operations
  288.  
  289.    o  Filtering by Extension
  290.  
  291.    o  No Icon (.info) files
  292.  
  293.    o  FileIO Flags
  294.  
  295.    o  DoFileIO() and DoFileIOWindow() are non-reentrant
  296.  
  297.    o  Procedure for Opening and Using the FileIO Requester library
  298.  
  299.    o  Displaying Lists of Strings (non-disk operation)
  300.  
  301. ========================== Basic Operation ============================
  302.  
  303. The FileIO routines base all of their work on a data structure called 
  304. the FileIO structure.  You are allocated one of these structures when you
  305. call the GetFileIO() routine.  The structure is initialized with reasonable
  306. default values for you. Conversely, you can declare and pre-initialize a
  307. FileIO structure as long as all fields are set to zero or an appropriate
  308. value. At the very least, you must set the FileIO's Buffer field to point to
  309. where you want string input stored, and initialize the DrawMode, PenA, and
  310. PenB fields to desired values. The buffer size should be > = 202 bytes.
  311.  
  312. The FileIO structure is used when calling the DoFileIO() and DoFileIOWindow()
  313. routines, which are the routines that actually present the requester to
  314. the user and get the user's filename selection. DoFileIOWindow() is the same
  315. as DoFileIO() except that the former opens a window for the requester. With
  316. DoFileIO(), you must already have a window open.
  317.  
  318. There are several flags and data fields in the FileIO structure that you
  319. may choose to initialize before calling DoFileIO(). By setting or clearing
  320. these flags, you define how information is to be presented to the user.
  321. These flags are described below in "FileIO Flags". Also, the user can
  322. change these flags for each FileIO via the function keys.
  323.  
  324. The DoFileIO() function returns one of 2 values:
  325.  
  326. 1). The address of the buffer where the complete pathname (disk, drawer,
  327.     and filename as one, NULL-terminated string) has been stored. This
  328.     buffer will be the one that you supply in the FileIO's buffer field.
  329. 2). A -1 if the user selected the cancel gadget.
  330.  
  331. The DoFileIOWindow() function may return this additional value:
  332.  
  333. 3). A zero if the window didn't open.
  334.  
  335. You can call these routines any number of times with the same FileIO
  336. structure. Also, your program can have more than one FileIO structure at a
  337. time. An example of why you would want more than one FileIO structure: you
  338. might want to have separate structures for getting input filenames and
  339. output filenames from the user.  Another example:  you might have one
  340. structure for letting the user select text files and another for the
  341. selection of graphics files each with different options/features. Also,
  342. there are some lib routines that do not deal with disk file IO, but use the
  343. FileIO structure nonetheless and you might want a FileIO with a special
  344. string buffer for these routines.
  345.  
  346. Finally, when you're finished with your FileIO structure (usually not until
  347. your program is terminating) then you call ReleaseFileIO() to deallocate all
  348. the resources that it's accumulated. If the FileIO was obtained via
  349. GetFileIO(), this routine also frees it for you.
  350.  
  351. ====================== DoFileIO() is non-reentrant ========================
  352.  
  353. The DoFileIO() routine is non-reentrant.  For the sake of memory efficiency,
  354. it uses global data and variables rather than creating local copies of these
  355. for each caller. What this means is that only 1 task can use the library
  356. functions DoFileIO() or DoFileIOWindow() at a time, though all other lib
  357. functions are re-entrant. If you attempt to call DoFileIO() or DoFileIOWindow()
  358. while another task is using it, the library will automatically prompt the
  359. user to type in the complete filename, instead of displaying the requester.
  360. The area where the user types in the filename is in the title bar of the
  361. window where the requester opened. The prompt
  362.  
  363.    Filename >
  364.  
  365.  will be displayed in the window's titlebar, along with a cursor. Several
  366. line editing features are supported including cursor key movement (with the
  367. ability to insert characters), backspace, delete, shift-right and shift-left
  368. cursor to the start and end of the string, and escape. The window's title is
  369. later restored. In fact, this feature of being able to use the title bar for
  370. getting user input can be used with your own prompts. It is a handy alterna-
  371. tive to having a string gadget (which takes up window space and also requires
  372. allocating several structures), plus allows for displaying custom prompts.
  373.  Note that many tasks can open the library simultaneously, but only 1 can be
  374. displaying the FileIO requester at a given moment.
  375.   This redirection to entering the filename via the title bar is completely
  376. invisible to your application. Upon return from DoFileIO() or DoFileIOWindow()
  377. you will receive one of the 2 (or 3), previously described return values.
  378.  
  379. ========== Interpreting the return value of DoFileIO() ================
  380.  
  381.   As mentioned before, there are 3 possible return values from DoFileIOWindow
  382. and 2 returns from DoFileIO(). If there is not enough memory for the window
  383. to open with DoFileIOWindow(), then the return value is 0 and the FileIO's
  384. Errno field = ERR_WINDOW. If this happens, you will have to find another way
  385. to get the filename. If you already have a window open, use DoFileIO(). This
  386. routine will never fail. Alternately, you might have the user type the path
  387. as he would from the CLI, and call ParseString() to put it in the FileIO.
  388.   If the user selects the CANCEL gadget, (or hits ESCAPE when entering the
  389. filename in the titlebar, or RETURN with no chars input), both routines will
  390. return -1.
  391.   In all other cases, the address of the FileIO's Buffer will be returned.
  392. This indicates that the user selected OK, or typed something in the string
  393. gadgets or title bar. This does not mean that the filename is valid for
  394. your purpose though. Let's assume that you called DoFileIO() from a load
  395. routine. Naturally, you want the user to select an existing file to load,
  396. but let's say that he types a non-existant file in the Name gadget or just
  397. selects a disk or drawer without eventually choosing a file before selecting
  398. OK. You can determine what the user did by examining 2 FileIO fields. The
  399. FileIO's Filename buffer contains just the filename portion of the complete
  400. path (separated from all the drawer and disk names). If this buffer is NULL,
  401. then the user did not select a filename. If the buffer is not NULL, then he
  402. either selected a filename, or typed one in. If he typed one in, how do
  403. you know if the filename exists? The FileIO's FileSize field will be 0 if
  404. the filename doesn't exist (or couldn't be examined because the user refused
  405. to mount the file's disk). In this case, you would abort the load. If the
  406. FileSize is not 0, then the file exists and this is how large it is in bytes.
  407. In conclusion, here are the steps you should take for a load routine:
  408.  
  409. 1). Call DoFileIO() with the FileIO's Buffer set to the address of your
  410.     path buffer, and the DrawMode, PenA, and PenB fields initialized.
  411. 2). Examine the return. If -1, then CANCEL. (If 0 for DoFileIOWindow, then
  412.     get the filename another way).
  413. 3). Check the FileIO's filename buffer for NULL. If NULL, then abort load
  414.     posting "This is not a loadable file."
  415. 4). Check the FileIO's FileSize field. If zero, post "File doesn't exist."
  416. 5). Otherwise, use the path buffer to open the file for reading.
  417.  
  418.  Here are the steps you should take for a save routine:
  419.  
  420. 1). Same as load routine step 1
  421. 2). Same as load routine step 2
  422. 3). Check the filename buffer for NULL. If NULL, then abort posting
  423.     "Did not supply a filename."
  424. 4). Check the FileSize field. If it's not 0, then the user must have selected
  425.     a filename that already exists on the chosen disk and in the specified
  426.     drawer. Post "File exists. Should we overwrite it?" Get a yes or no
  427.     response from the user to continue or abort.
  428. 5). Otherwise, use the path buffer to open the file for writing.
  429.  
  430. ======================== Internal Error Handling ==========================
  431.  
  432.   The requester is set up so that if the user types in a non-existant disk
  433. name or refuses to mount the chosen disk, the req will default to any other
  434. mounted disk. If no disks mounted, then the default FILEIO_DISKNAME is ":".
  435. For example, assume that the user types "Leroy:" in the disk string gadget, 
  436. but the disk is not in any drive. AmigaDOS will prompt for that disk. If
  437. the user then CANCELs the system prompt, the FileIO req will display the
  438. contents of some other disk that is mounted, adjusting the string gadgets
  439. accordingly. In the case where no disks are mounted, the pathname buffer
  440. that is returned will not contain any disk name.
  441.   If the user types a drawer name that is not in the current dir level, the
  442. req will knock him back to the root of the current dir. For example, assume
  443. that the user is looking inside of a drawer called "TireBiter". There is no
  444. drawer called "George" inside here, but the user types this in the drawer
  445. string gadget nonetheless. The requester will clear ALL the drawer names,
  446. defaulting to the root of the disk.
  447.   The library will not return non-existant disk or drawer names. If you needed
  448. the requester to do this though (maybe you want to pass the path buffer to
  449. CreateDir) then the user should type the "new" drawer name by itself in the
  450. Name gadget. Conversely he could enter the string via the titlebar like so:
  451.  
  452.   WorkBench:Demos/Blort
  453.  
  454.  where you simply treat Blort as a dir name instead of a filename. The lib
  455. will copy Blort to the FileIO's Filename field nonetheless. Just check the
  456. FileSize field to make sure that there isn't a file already named this.
  457.   If there is some error in obtaining the disk name and it defaults to ":",
  458. then the returned pathname will not have a drawer name prepended to it.
  459. For example, say the user typed "df0:" in the drawer string gadget, but the
  460. drive was empty. The requester will automatically default to another mounted
  461. disk/device, etc, until one can be examined, or finally ":" is used. If the
  462. user then types "Papoon" in the Filename Gadget, the returned path will be:
  463.  
  464.   Papoon
  465.  
  466. which will be stored in the FileIO's Filename buffer if its a Filename, or
  467. the FileIO's Drawername buffer if it's a drawer. If it is a Filename that
  468. exists in the current dir, the FileSize will be its size in bytes.
  469.  
  470. ================= Quick Display (NO_CARE_REDRAW) ================
  471.  
  472.   The data in the FileIO structure often remains valid between calls to
  473. DoFileIO(), so with subsequent calls a flag has been provided to avoid
  474. reconstructing the filename list. This allows the requester to appear very
  475. quickly because the usually-lengthy process of accessing the disk is avoided.
  476. Other times, it may be necessary to have the requester reconstruct its list
  477. of filenames (i.e. when a disk is changed or a file created/deleted by an
  478. application which does not communicate with the FileIO requester). Perhaps,
  479. as in a save routine, it may not be important to show the user what other
  480. recent files are on the disk as long as proper file protection is provided.
  481. The library uses the NO_CARE_REDRAW flag to discern whether to reconstruct
  482. the list, or simply to use the FileIO's previous names. If you set this flag,
  483. the old list is simply redrawn. Once you set this flag, the list will not
  484. be reconstructed on subsequent calls until you explicitly clear NO_CARE_REDRAW.
  485. (i.e. you always get the same, non-updated list unless the user changes dirs
  486. or disables the feature himself via the Function keys).
  487.    When GetFileIO() creates a FileIO structure for you, this flag is cleared
  488. to specify that the structure doesn't contain an updated list of filenames.
  489. Thus the first call to DoFileIO() causes the filename list to be constructed.
  490. After the call to DoFileIO() is the time to set the flag. You must do a bit
  491. of work if you wish to make use of this feature. You are obliged to watch
  492. for IDCMP events of class DISKINSERTED and to clear the NO_CARE_REDRAW flag
  493. in any of your FileIO structures whenever you see this event. The
  494. DISKINSERTED event occurs when the user has switched around the disks. When
  495. the user has changed disks, you can't be sure that your FileIO's filename
  496. list is still valid, so as a courtesy to the user you must cause the filename
  497. list to be reconstructed. In the case that some disk activity occurs in a
  498. program that doesn't use the FileIO library, you will never know about this
  499. activity. Also, if the disk is changed or files are created/deleted by some
  500. other task using the library, you will have no way to determine this. For
  501. these reasons, you may elect to forgo this feature entirely. If you don't use
  502. this feature, you need not bother looking for DISKINSERTED events. Because
  503. the library has been completely rewritten in optimized assembly, it doesn't
  504. take too long for the requester to construct its list anew. Also, the user
  505. can toggle this feature ON/OFF using function key 6 if he wants. The example
  506. applications don't use this feature. You can use the FileIO Requester library
  507. to get the name of a file to be used for output.  If you do, and the
  508. specified file doesn't currently exist, AmigaDOS will create it anew when
  509. you open it (mode NEWFILE). From the FileIO Requester point of view, this
  510. means that a file now exists that isn't in your FileIO list.  To get the name
  511. in the list, clear the NO_CARE_REDRAW (if it was SET). The next time that
  512. the FileIO structure is used for a call to DoFileIO() or DoFileIOWindow(),
  513. the new file name will appear alphabetized in with the other file names.
  514. Once again, this is not applicable if you don't ever set NO_CARE_REDRAW.
  515.    If you have more than one FileIO structure, remember that you must clear
  516. the NO_CARE_REDRAW flag in all of them whenever you see Intuition's
  517. DISKINSERTED IDCMP event class (if you're using the NO_CARE_REDRAW feature).  
  518. Also, regarding new disks, there's an extra procedure that you must follow.  
  519. If the user changes the disk while you've called DoFileIO() or DoFileIOWindow(),
  520. you won't actually see a DISKINSERTED event (as the event will have been 
  521. processed by the library before control is returned to you). So how will you
  522. know to clear the NO_CARE_REDRAW flag in your other structures?  Well, the
  523. library records the fact that a DISKINSERTED event was handled by setting
  524. the DISK_HAS_CHANGED flag in your FileIO structure. So on return from a call
  525. to DoFileIO() or DoFileIOWindow you should check to see whether your FileIO
  526. structure has the DISK_HAS_CHANGED flag set. If it does, you should clear
  527. the DISK_HAS_CHANGED flag in the structure and then clear the NO_CARE_REDRAW
  528. flag in all of your other FileIO structures.  This assures that when you
  529. call DoFileIO() with any of your other support structures, the filename lists
  530. will be reconstructed, as they should. Please note that all this needs to be
  531. done ONLY IF YOU'RE SETTING NO_CARE_REDRAW.
  532.  
  533. =============== Workbench-style Filename Operations ====================
  534.  
  535. You can have file names appear in the FileIO Requester using the same rules
  536. that govern how files appear on the Workbench display, by using the Workbench
  537. .info file mechanism.  
  538.  
  539. To attempt to match Workbench patterns, you must set the WBENCH_MATCH flag
  540. in your FileIO structure, as described below.
  541.  
  542. The Workbench .info file mechanism is a detailed topic that will not be 
  543. delved into here.  Please read the Amiga ROM Kernel Manual for a description
  544. of the Workbench operation and data types.  What follows is a cursory
  545. description of the Workbench technique, which is described only well enough
  546. to explain how you can interact with it via your FileIO structure.  
  547.  
  548. The Workbench program examines the directory of a disk and displays icons
  549. for the files it finds that end with a ".info" suffix (hereafter referred to
  550. as .info files).  The file names displayed beneath the icons have the
  551. ".info" suffix removed.  The Workbench .info files contain information
  552. regarding what type of data is contained in the file (executable program,
  553. project data, et cetera).
  554.  
  555. You can choose to have only .info files displayed to the user (with the
  556. ".info" removed) in the same way that the Workbench does. You get this
  557. by setting the WBENCH_MATCH flag. Any executables without icons (.info files
  558. ) will not be displayed. The same is true of drawers.
  559.  
  560. If you wish, you can further filter the names that appear. There are two
  561. techniques that you can employ for filtering which file names will be added
  562. to the list:  you can ask for only those files that match a particular
  563. Workbench object type and only those files that match a particular tool type.  
  564.  
  565. You elect to match the object type by setting the MATCH_OBJECTTYPE flag in
  566. your FileIO structure.  The object types typically of interest are WBTOOL
  567. and WBPROJECT.  By selecting one of these 2 types, your filename list will
  568. consist only of executable files or data files respectively (except that all
  569. .info drawer names are always displayed). If this is confusing, refer to the
  570. ROM Kernel manual for a discussion of object types.  
  571.  
  572. You can also request to match a Workbench tool type.  By matching tool types,
  573. you can, for instance, have your file list display only those data files
  574. that were created by a specific application.  See the section entitled
  575. "The ToolTypes Array" in the Workbench chapter of the ROM Kernel manual for
  576. a description of how tool types work.  You elect to match tool types by
  577. setting the MATCH_TOOLTYPES flag in your FileIO structure.  A pointer to the
  578. ToolTypes text that you must supply should be stored in the ToolTypesText
  579. field of your FileIO structure.
  580.  
  581. =========================== No Info Files ============================
  582.  
  583.   Setting the INFO_SUPPRESS flag is exactly the opposite of Workbench
  584. matching. All files that end in .info will be ignored, and not displayed.
  585. This is handy if the user doesn't have a .info file to go with every file
  586. that he wishes to peruse. With WB MATCH, those files would not be displayed.
  587. With INFO_SUPPRESS set, they would be displayed but no .info files would
  588. clutter the display. This gives the impression of WB MATCH while enabling
  589. files without icons to also be seen. On the down side, that means that the
  590. user will see ALL files without icons including those that are best left
  591. alone (i.e. translator.library). All drawers are displayed regardless.
  592. When the user makes his selection, the .info is not added to the pathname.
  593.  
  594. ==================== Filtering by Extension =====================
  595.  
  596.    Sometimes, you may have an application that only wants to see filenames
  597. that end with a certain string (i.e. ".iff"). You can specify an extension
  598. by storing the address of this string in the Extension field of the
  599. FileIO. Also, you need to specify the length (don't count the terminating
  600. NULL byte) and store this value in the ExtSize field. For the preceding
  601. example, the length would be 4 (counting the .). Finally, you must set the
  602. EXTENSION_MATCH flag. If the EXTENSION_MATCH flag is clear, the extension
  603. fields will be ignored. In this way, you can quickly enable and disable the
  604. feature with the one flag. Only the files that END with this extension (case
  605. insensitive) will be displayed. Incidentally, this need not be a real exten-
  606. sion. You can match any ending at all. For example, you could only display
  607. those files that end with the string "picture". In this case, the length
  608. would be 7. If you set the EXTENSION_MATCH flag, then clear the INFO_SUPPRESS
  609. flag. Because only those files that end in your specified extension are seen,
  610. .info files won't be displayed anyway (unless your specified extension is
  611. ".info" in which case you'll get nothing but .info files. An icon editor,
  612. maybe?) All drawers will be displayed regardless. Please note that the
  613. extension string that you supply MUST HAVE ALL LETTERS IN LOWER CASE.
  614.   In order for the user to take advantage of this feature via the F4 key,
  615. you must set up the FileIO for it. First you must supply a buffer for the
  616. user's typed extension. Place the address in the FileIO's Extension field.
  617. The buffer must be at least 20 bytes long. Don't enable the EXTENSION_MATCH
  618. flag.
  619.   If you don't want the user to take advantage of extension match, then
  620. clear the EXTENSION_MATCH flag AND zero the Extension pointer field. There
  621. is the possibility that you may have supplied an Extension to be matched
  622. and while the requester was displayed, the user changed the match string.
  623. For this reason, the buffer should always be at least 20 bytes if you use
  624. this feature. Also, don't assume that the returned filename is definitely
  625. ending with the extension you initially passed. If the user changed the
  626. match string, it won't be the same extension. Also, you should re-initialize
  627. your extension buffer string each time before you call DoFileIO(). The
  628. returned pathname and FILEIO_FILENAME buffer have the extension added.
  629.  
  630. ========================== FileIO Flags ===========================
  631.  
  632.  Remember that the user can always adjust these himself with the function
  633.  keys. For this reason, you might simply go with the defaults.
  634.  
  635. NO_CARE_REDRAW
  636.     This flag designates whether the filename data contained in the 
  637.     FileIO is to be reconstructed before initially drawing the requester.
  638.  
  639. USE_DEVICE_NAMES
  640.     When you leave this flag CLEAR, the AmigaDOS volume names will
  641.     be used for the disk names in the requester.  If you SET
  642.     this flag, the device names will be used instead. The default is to
  643.     follow the Workbench convention and use volume names.
  644.  
  645. DISK_HAS_CHANGED
  646.     If the user changes the disk while the FileIO Requester is being
  647.     displayed, this flag is set in the FileIO structure. The only time you
  648.     must pay attention to this flag is when you have set the NO_CARE_REDRAW
  649.     flag. If you find that DISK_HAS_CHANGED has been set, you must clear
  650.     that flag in this FileIO structure and then clear the NO_CARE_REDRAW
  651.     flag in all of your FileIO structures.
  652.  
  653. DOUBLECLICK_OFF
  654.     Normally, the user can double-click on a filename to select it.  
  655.     You may choose to disable this feature, for instance, when you want the
  656.     user to be very certain about the filename selection (perhaps if the
  657.     file is about to be destroyed, or something equally drastic). To disable
  658.     double-clicking, set the DOUBLECLICK_OFF flag.  Then the user will have
  659.     to explicitly select OK! or type the filename and hit return for the
  660.     selection to be made.
  661.  
  662. WBENCH_MATCH
  663.     You set this flag to specify that you want Workbench-style .info file
  664.     logic to be used when constructing the filename list. This flag is
  665.     cleared when your FileIO structure is first created.
  666.  
  667. MATCH_OBJECTTYPE
  668.     When you set this flag (and the WBENCH_MATCH flag), the MatchType field
  669.     of your FileIO structure will be compared with the do_Type field of the
  670.     .info file's DiskObject structure.  If they match, the file will be 
  671.     displayed.  Both the MATCH_TOOLTYPE and the MATCH_OBJECTTYPE flags can
  672.     be set at the same time.
  673.  
  674. MATCH_TOOLTYPE
  675.     If you set this flag (and the WBENCH_MATCH flag), then Workbench-style
  676.     ToolType pattern matching will be performed and must be successful
  677.     before the filename will be included in the list.  You specify your
  678.     selection of ToolType in the FileIO structure's ToolType pointer field.
  679.     Both the MATCH_TOOLTYPE and the MATCH_OBJECTTYPE flags can be set at 
  680.     the same time.
  681.  
  682. INFO_SUPPRESS
  683.     All .info files are suppressed from the display if you SET this.
  684.  
  685. EXTENSION_MATCH
  686.     Filters filenames that end with a certain string if you SET this.
  687.  
  688. CUSTOM_HANDLERS
  689.              Allows adding custom handlers to the internal library
  690. handlers of GADGETUP, GADGETDOWN, MOUSEMOVE, RAWKEY, DISKINSERTED,
  691. and initial REQSET. You can supply an additional handler for any and all of
  692. these events that will be invoked along with the internal library handler
  693. (or in place of it). Once you call DoFileIO(), the handlers will be installed
  694. and active until the requester ends. Set or Clear this flag before calling
  695. DoFileIO(). If the requester can't open or is being used by another task,
  696. the user will get titlebar entry, and your handlers will be ignored.
  697.  
  698. SPECIAL_REQ
  699.      Allows using the FileIO requester to display lists of strings not
  700. relating to disk drive operations.
  701.  
  702. ======================= RAM DISK bug ============================
  703.  
  704.    There seems to be a bug in 1.2 AmigaDOS. For some reason, whenever one
  705.    attempts to get an AmigaDOS Lock on the volume named "RAM DISK:" a
  706.    software error occurs.  The problem doesn't necessarily lie in AmigaDOS, 
  707.    but the truth is that the error occurs with little provocation 
  708.    of AmigaDOS (for instance:
  709.         dir "RAM DISK:"
  710.    can and does crash the Amiga).  Though 1.3 resolves this bug, the FileIO
  711.    code provides a work-around for 1.2 by changing "RAM DISK:" to "RAM:"
  712.    which locks successfully and does not crash the machine. This solution
  713.    has a problem:  if the user has given the name  "RAM DISK:" to some
  714.    non-RAM: disk (such as a floppy) then this fix will fail and the floppy
  715.    named "RAM DISK:" wouldn't be seen. This isn't too bad of a problem,
  716.    because if the user has been silly enough to name a floppy "RAM DISK:"
  717.    the user is probably experiencing lots of other problems already and this
  718.    will provide just one more reason why one shouldn't name a floppy 
  719.    "RAM DISK:" don'cha know.
  720.  
  721. ======================= Free Disk Space ================================
  722.  
  723.   The FileIO's FREEBYTES field indicates how many free bytes remain on the
  724. disk that the user has chosen. This is useful for a save routine. After all,
  725. you wouldn't want to start saving a 230K file to a disc that only has 229K
  726. free. Unfortunately, AmigaDOG always says that the RAM DISK: has 0 bytes
  727. free. Actually, it has as many bytes free as mem that is available. Whenever
  728. the user selects RAM: or RAM DISK:, the FileIO's FREEBYTES is set to
  729. 0xFFFFFFFF (the largest size possible). If you encounter this condition, you
  730. may wish to use Exec's AvailMem to determine if you can do the save.
  731.  
  732. ========== Procedure for Using the FileIO Requester library ===========
  733.  
  734. This section presents a step-by-step procedure for utilizing the FileIO
  735. Requester library with your own program.
  736.  
  737. Copy the requester.library into the libs directory of your boot disk. For
  738. workbench users, double-click on the inclosed program "CopyLib" and place
  739. your Workbench disk in the drive when you see the DOS requester. CopyLib
  740. will display the FileIO requester if all went well. Select the requester's
  741. CANCEL and exit the program by closing the window.
  742.  
  743. You have to include FileIO.h in every C module that refers to your FileIO
  744. structure.
  745.  
  746.     #include "FileIO.h"
  747.  
  748.  For assembly language users, (WOW! We hardly ever get real support for
  749.  programming on the Amiga), include FileIO.i
  750.  
  751. Open the library via a call to exec's OpenLibrary and store the pointer at
  752. a variable called RequesterBase (MUST BE CALLED THIS FOR C PROGRAMMERS).
  753.  
  754.    if (!(RequesterBase = (APTR) OpenLibrary("requester.library", 0L)))
  755.    exit(0);
  756.  
  757. Declare a pointer to a FileIO structure (initialized to 0), and then fill
  758. that pointer with the address of one of the structures.
  759.  
  760.     struct FileIO *myFileIO = 0;
  761.  
  762.     myFileIO = GetFileIO();
  763.  
  764.                 <<<< IF USING NO_CARE_REDRAW >>>>>
  765. Your NewWindow structure should have the DISKINSERTED flag set along with 
  766. your other IDCMP flags.  Whenever you receive a DISKINSERTED event, you 
  767. should clear the NO_CARE_REDRAW flag (if SET) in every FileIO structure you
  768. control.  The following code could be added to the case switch where you 
  769. handle IDCMP events.
  770.  
  771.     switch (imessageclass)
  772.         {
  773.         case DISKINSERTED:
  774.             /* You should clear the NO_CARE_REDRAW flag
  775.              * whenever you detect that a new disk was 
  776.              * inserted.
  777.              */
  778.             if (myFileIO)
  779.                 ClearFlag(myFileIO->Flags, NO_CARE_REDRAW);
  780.             break;
  781.         }
  782.  
  783. Alternately, you may elect to leave NO_CARE_REDRAW clear in which case the
  784. requester display will be updated every time it is used and you won't need
  785. to bother with receiving DISKINSERTED events.
  786.  
  787.   Set the FileIO's Buffer field to the address of a buffer that you have
  788. allocated. This is where the complete path will be constructed for you.
  789. (i.e  Disk:drawer1/drawer2...etc/filename ) Also initialize the FileIO's
  790. DrawMode, PenA, and PenB. You might also want to set the FileIO's X and Y
  791. fields where the requester will open within your window (relative upper left).
  792. If using DoFileIO(), and your window is not full size, include a sizing
  793. gadget so that if the user needs to type via the title bar he can expand it.
  794.  
  795. When you want to present the FileIO Requester to the user, call DoFileIO() or
  796. DoFileIOWindow(). If these routines return the address of the passed buffer
  797. where you want the full path name to be stored, the user did not cancel the
  798. operation, nor was there an error in opening the window (for DoFileIOWindow
  799. only). A -1 and 0 will be returned respectively for the two error conditions.
  800. The following code is an example of presenting the FileIO Requester to the
  801. user and then reacting to the result.
  802.  
  803.   /* This set-up need only be done once, though you can change them later */
  804.  
  805.    UBYTE buffer[204];
  806.  
  807.    myFileIO->Buffer = buffer;
  808.    myFileIO->DrawMode = JAM1;
  809.    myFileIO->PenA = 1;
  810.    myFileIO->PenB = 0;
  811.  
  812.   /* ================================================================ */
  813.  
  814.    if (myFileIO)
  815.    {
  816.        result = (DoFileIO(myFileIO, window));
  817.     if (result==&buffer[0])
  818.        {
  819.             /* Here, do something like read or write the file.
  820.              */
  821.            if (writefile)
  822.            {
  823.             if (myFileIO->FileName[0])
  824.               {
  825.                if (!myFileIO->FileSize)
  826.                {
  827.                 /* Open the file (MODE_NEWFILE) */
  828.                 /* Write the file */
  829.                 /* Close the file */
  830.                }
  831.                 /* Otherwise, tell the user that he's about to overwrite */
  832.               }
  833.                 /* Error in entering filename */
  834.            }
  835.            if (readfile)
  836.            {
  837.             if (myFileIO->FileName[0])
  838.               {
  839.               if (myFileIO->FileSize)
  840.                {
  841.                 /* Open the file (MODE_OLDFILE) */
  842.                 /* Read the file */
  843.                 /* Close the file */
  844.                }
  845.                 /* Otherwise, tell the user that the file doesn't exist */
  846.               }
  847.                /* Not a loadable file */
  848.            }
  849.        }
  850.      if (result==0)
  851.        {
  852.           /* This only happens if DoFileIOWindow() bombs. Call DoFileIO() */
  853.        }
  854.    /* Otherwise, CANCEL must have been selected. Never mind. */
  855.    }
  856.  
  857. Finally, when you're done with your FileIO structure (usually when
  858. your program is exiting), you can free up the structure and its resources
  859. with a simple call to ReleaseFileIO(), like this:
  860.  
  861.     if( RequesterBase ) ReleaseFileIO(myFileIO);
  862.  
  863. Also, you need to close the library upon exit.
  864.  
  865.     if( RequesterBase ) CloseLibrary( RequesterBase );
  866.  
  867.   When you link your C program, you'll need to assemble and link with
  868. FileInterface.asm. This is the usual assembly poot needed by C programs in
  869. order to call assembly language libraries. You want efficiency, write in
  870. assembly. Assembly programmers can simply use the _LVO library offsets as
  871. provided in FileIO.i. See the example applications for details.
  872.  
  873.   ONE FINAL NOTE: The lib needs to trap RIGHT MOUSE buttons for displaying
  874.   the list of disk names. When exiting, the lib clears the RMBTRAP bit of
  875.   your window's flags, so if you had it set before calling DoFileIO(), then
  876.   you'll have to set it again upon return by going to the Flags field of
  877.   your window structure and setting bit #16.
  878.  
  879. ============ USING THE REQUESTER TO DISPLAY LISTS OF STRINGS =============
  880.  
  881.    There may be times when you need to display a list of strings in a
  882. requester so that a user can scroll around the list via the mouse and
  883. choose an item in the list. The amount of code and IDCMP hassle of construct-
  884. ing such a requester can certainly be considerable, especially if you want to
  885. include a Prop scroll bar, scroll arrows, a string gadget, CANCEL and OK
  886. gadgets, etc.
  887.    The latest version of the FileIO requester library has a feature whereby
  888. you can use the lib's requester to display your list of strings. The lib
  889. handles all user interaction, list display, and IDCMP. You simply set the
  890. SPECIAL_REQ flag of the FileIO before calling DoFileIO() or DoFileIOWindow()
  891. and the requester will display your list of strings. The requester is no
  892. longer a disk I/O tool. In fact, the Disk and Drawer string gadgets are re-
  893. moved from the display, and the NextDisk gadget no longer has anything to do
  894. with switching dirs.
  895.    The user can employ the Prop and Arrow gadgets (with auto-scroll) to scroll
  896. through the list of strings. The size of the Prop's knob reflects the per-
  897. centage of visible strings just like in the disk I/O version.
  898.    The user can click on any string to make it the currently selected one,
  899. and it will be highlighted and copied to a string gadget below. Or the user
  900. can type his selection directly into the string gadget. A double-click on
  901. a string will end the requester with that string as the chosen one.
  902.    The chosen string will be copied to the FileIO's Filename buffer. Note
  903. that with SPECIAL_REQ, you do not need a Pathname buffer. (In fact, the
  904. FileIO's BUFFER field will be overwritten.)
  905.    With SPECIAL_REQ, DoFileIO() or DoFileIOWindow will return the following:
  906.  
  907.   1). A -1 if the user selected the CANCEL gadget.
  908.   2). A -2 if the library was being used by another task (i.e. the same
  909.       note about non-reentrant code applies here).
  910.   3). A 0 if there is a problem opening the FileIO window (for DoFileIOWindow)
  911.   4). The address of the FileIO's Filename buffer (i.e. where the selected
  912.       string is copied) if all went well and the user selected OK, or double-
  913.       clicked on a string, or typed in his selection in the Name gadget.
  914.  
  915.    So how do you give your list of strings to the lib? There are 2 new
  916. functions, NewEntryList() and AddEntry() that you use to make the list.
  917. Here are the passed parameters.
  918.  
  919.    EntryNum = AddEntry(ID_num, StringAddress, FileIO);
  920.       d0                 d1         a0          a1
  921.  
  922.    NewEntryList(FileIO);
  923.                   a1
  924.  
  925.    Each FileIO can have its own list attached to it. NewEntryList frees
  926. any previous list (if one exists) that was made for the passed FileIO. For
  927. this reason, you should call NewEntryList first before using AddEntry to
  928. add strings. You can then add strings to the list by subsequent calls
  929. to AddEntry. (AddEntry adds the one passed string into the list. The list is
  930. alphabetized as each string is added to it so that the strings are always
  931. displayed in alphabetical order.) ID_num is some value that you want asso-
  932. ciated with the string. When the user selects that string, it is copied into
  933. the FileIO's Filename buffer and the ID is copied into the FileIO's FileSize
  934. field. This ID is a LONG, and can be any value you desire (i.e. maybe even
  935. a pointer to some data structure associated with that string). The only
  936. restriction is that ID cannot be -1 (i.e. 0xFFFFFFFF).
  937.    The returned EntryNum is where the string has been alphabetically placed
  938. in the list (i.e. the first string in the list returns 0). If you receive
  939. a negative number from AddEntry(), this means that there wasn't enough memory
  940. to add the string to the list. Actually, AddEntry copies the string, and
  941. adds the copy to the list, so you need not keep the original string after it
  942. is added to the list.
  943.    When you finally call ReleaseFileIO(), any list associated with the FileIO
  944. is freed.
  945.    Here is how you might create a list with the following 3 items and display
  946. it in the FileIO requester:
  947.  
  948.    /* You should have opened the requester lib and allocated a FileIO */
  949.  
  950.    if (myFileIO)
  951.    {
  952.        NewEntryList(myFileIO);
  953.        error = AddEntry(1L, "This is One", myFileIO);
  954.        if (error<0) break;
  955.        error = AddEntry(2L, "Two", myFileIO);
  956.        if (error<0) break;
  957.        error = AddEntry(3L, "Three", myFileIO);
  958.        if (error<0) break;
  959.  
  960.        result = (DoFileIO(myFileIO, window));
  961.     if (result==myFileIO->FileName)
  962.        {
  963.             /*  FileName buffer contains the string, and FileSize the ID
  964.              */
  965.        }
  966.      if (result==0)
  967.        {
  968.           /* This only happens if DoFileIOWindow() bombs. Call DoFileIO() */
  969.        }
  970.      if (result==-2)
  971.        {
  972.           /* This happens if someone is using the library. Come back later */
  973.        }
  974.    /* Otherwise, CANCEL must have been selected. Never mind. */
  975.    }   
  976.  
  977.    There is a possibility that the user may type a string that is not in the
  978. list, directly into the Name gadget. Before exiting, the requester lib will
  979. check if the string is in the list. If not, the string is copied to the
  980. FileIO FileName buffer as before, but the FileSize field is set to -1. A
  981. FileSize of -1 means "this string isn't in the list". That is why you should
  982. not assign an ID of -1 to any string. The lib ignores the case of the string
  983. when comparing items in the list (i.e. "Amiga" and "amIGA" are the same),
  984. but it does not trim away any leading or trailing spaces.
  985.  
  986.    With SPECIAL_REQ, the "Next Disk" gadget can be a custom gadget for your
  987. use. You place into the FileIO's FileIOText field a pointer to the string
  988. that you want displayed in the gadget. This string should be no more than 11
  989. characters (not counting the end NULL). You should pad the head of the
  990. string with spaces to properly center inside the gadget. You should also
  991. store in the FileIO's FileIORoutine field a pointer to a routine that is to
  992. be executed everytime the user releases the mouse over the custom gadget.
  993. The library calls this routine passing the FileIO and Window (that the
  994. requester opened in), and the Requester Structure.
  995.  
  996.    BOOL  yourRoutine(Requester, Window, FileIO)
  997.                        a5         a3      a2
  998.  
  999.    This function should return TRUE to end the requester, or FALSE to con-
  1000. tine. If FALSE, the FileIO display will be refreshed when your function
  1001. returns. (In case your custom routine added/removed something from the list,
  1002. or changed lists). If you return TRUE, the requester will end with the
  1003. FileIO's Errno field will be set to ERR_APPGADG.
  1004.    If your FileIO's FileIORoutine field is set to NULL when you call
  1005. DoFileIO, the custom gadget is removed from the display.
  1006.  
  1007.    Finally, there is a routine that you can use to determine if a certain
  1008. string is in the list.
  1009.  
  1010.    entryNum = IsEntryThere(String, FileIO)
  1011.      d0                      a0      a1
  1012.    where String is the address of the string you wish to check for.
  1013.    This returns the entryNum (like AddEntry) of the string if it is found
  1014.    in the list, or a -1 if it is not in the list. For assembly programmers,
  1015.    if found, the address of the Remember structure is returned in a0.
  1016.  
  1017.  
  1018.    The list is created using the Intuition function, AllocRemember. The
  1019.    "anchor" of the list is the FileIO's FileList field. So each string has
  1020.    its own Remember structure. The Remember's rm_Memory points to my own
  1021.    Entry structure. An Entry structure looks like this:
  1022.  
  1023. struct Entry   {
  1024.    LONG   EntryID;
  1025.    UBYTE  EntryFlags;  /* Don't alter this! */
  1026.    UBYTE  EntryString[size of the string not counting end NULL];
  1027.    };
  1028.  
  1029.    In asm,
  1030.  
  1031. EntryID     dc.l 0
  1032. EntryFlags  dc.b 6
  1033. EntryString dc.b [the bytes comprising the NULL-terminated string]
  1034.  
  1035.    You can use one FileIO to alternately display several lists. The key is
  1036. to properly set the FileIO's NameCount, NameStart, CurrentPick, and FileList
  1037. fields before calling DoFileIO(). You should make a list as in the above
  1038. example, and then copy the FileList field to some global. Then zero out the
  1039. FileList field. Do this for all your lists. Now when you want to display one
  1040. list, pass the appropriate global to a routine that does the following:
  1041.    1). Clear the FileList field.
  1042.    2). Call NewEntryList() (to initialize the NameStart and CurrentPick)
  1043.    3). Set the FileIO's NameCount to the number of items in the list
  1044.    4). Set the FileIO's FileList to the passed global.
  1045.    5). Set the SPECIAL_REQ flag. (If it wasn't set previously.)
  1046.    6). Call DoFileIO()
  1047.    7). Clear the FileList field.
  1048.  
  1049.   Here's a C function to implement the above. It returns TRUE if all went
  1050. well, and FALSE if error or user cancel.
  1051.  
  1052. BOOL ShowList(ListAddr,NumOfItems,window,fileio)
  1053. struct Remember *ListAddr; /* the contents of the FileIO's FileList field
  1054.                               after you made the list with AddEntry(). */
  1055. SHORT NumOfItems;          /* number of entries in Remember List */  
  1056. struct Window *window;
  1057. struct FileIO *fileio;
  1058. {
  1059.    UBYTE *address;
  1060.  
  1061.    fileio->FileList = 0;  /* original value you previously stored in global
  1062.                              after making the list */
  1063.    NewEntryList(fileio);
  1064.    fileio->NameCount = NumOfItems;
  1065.    fileio->FileList = ListAddr;
  1066.    SetFlag(fileio->Flags, SPECIAL_REQ);
  1067.    address = DoFileIO(fileio, window);
  1068.    fileio->FileList = 0; 
  1069.    if( address <= 0 )
  1070.        return( FALSE );
  1071.    else
  1072.       return( TRUE );
  1073. }
  1074.  
  1075.    When exiting your program, you must de-Allocate all the lists. For each,
  1076.    1). Set the FileIO's FileList to the passed global.
  1077.    2). Call NewEntryList()
  1078.  
  1079.  
  1080. void FreeProgList(fileio, filelist)
  1081. struct FileIO *fileio;
  1082. struct Remember *filelist;
  1083. {
  1084.    fileio->FileList = filelist;  /* original value you previously stored in global
  1085.                                    after making the list */
  1086.    NewEntryList(fileio);
  1087.    fileio->FileList = 0;
  1088. }
  1089.  
  1090.    Consult the examples, CustomList, for how to use SPECIAL_REQ.
  1091.  
  1092. =============================================================================
  1093. === DEMO PROGRAM NOTES ======================================================
  1094. =============================================================================
  1095.  
  1096. This section briefly describes the demo programs that drive some of the
  1097. FileIO Requester library's features. There is a C demo, an assembly demo,
  1098. and an AmigaBasic demo (no joke).
  1099.  
  1100. If you invoke the C or asm demos without a second argument, a window will be
  1101. opened in the Workbench screen.  If you invoke these demos with any second
  1102. argument, a hi-res screen will be opened for the requester window.
  1103.  
  1104. The C demo uses two FileIO structures to demonstrate the techniques that you
  1105. should use when managing multiple FileIOs. These techniques include processing
  1106. DISKINSERTED events and discovering on return from DoFileIO() that the
  1107. DISK_HAS_CHANGED flag is set. (As long as you're using the NO_CARE_REDRAW
  1108. feature). The first support structure, fileio1, is used in its vanilla state
  1109. as created by GetFileIO().  The other support structure, fileio2, is
  1110. initialized to do Workbench-style .info file handling where the filename
  1111. list will consist of only .info objects of type WBPROJECT. Also, fileio1
  1112. uses volume names and the other uses device names. You activate fileio1 when
  1113. you click the right mouse button. You activate fileio2 when you press any
  1114. key. Finally, when you do any of the selection techniques where you accept 
  1115. your selection, the pathname to your selection is displayed in a FileIO
  1116. autorequester. If you choose CANCEL to end the FileIO process, nothing happens.
  1117. To stop the program, click on the window close gadget (when the requester
  1118. is not displayed).
  1119.  
  1120. The assembly demo only uses 1 FileIO structure. There is a menu to
  1121. demonstrate various features. You should manually deselect the features
  1122. you want disabled, and select those that you want enabled. For example,
  1123. select CUSTOM to see how a custom handler is installed for the REQSET event.
  1124. Also, this program can look for files that only end in certain strings if
  1125. you select the EXTENSION menu item. When you enable the extension feature,
  1126. the application uses the PromptUserEntry() function. Notice how the prompt
  1127. appears in the window titlebar with a cursor. You can type in the string
  1128. that you want to match, and hit return. Now when you call up the requester,
  1129. only those filenames that end in that extension will be displayed (along
  1130. with any dirs). This works just like the F4 Function key option.
  1131.  
  1132. The amigabasic demo asks the user if he wants to display only those files
  1133. with a certain extension, and inputs the extension. Otherwise, it suppresses
  1134. all .info files. It then copies the pathname to a string variable which can
  1135. be better utilized for basic manipulation. Also this demos a few of the
  1136. library's autorequester functions. When running this program, the included
  1137. bmap for the FileIO requester library must be in the same directory.
  1138.  
  1139. Additionally, there are examples to demonstrate using the requester to dis-
  1140. play lists of strings.
  1141.  
  1142. ========================================================================
  1143.                    INSTALLING CUSTOM HANDLERS
  1144.  
  1145.  You can install custom handlers for any of several events that might occur
  1146. in the requester. You need to set the CUSTOM_HANDLERS flag of the FileIO, and
  1147. fill the FileIO's HandlerBlockPtr field with the address of a HandlerBlock
  1148. structure. The HandlerBlock structure (defined in FileIO.h) holds the
  1149. addresses of the handlers for REQSET, DISKINSERTED, GADGETDOWN (and UP),
  1150. RAWKEY, and MOUSEMOVE. If you have no handler for a particular event, NULL
  1151. its HandlerBlock field. Each FileIO can have its own custom handlers.
  1152.   For REQSET, and DISKINSERTED, if your handler returns a 1, then the
  1153. library's internal handler will be skipped. Otherwise, the library routine
  1154. will be executed if you return a 0.
  1155.   For GADGETDOWN and GADGETUP, your handler will be called only if the Gadget
  1156. ID is not one of the requester's gadgets. Your handler will be passed the ID
  1157. in d0 (as well as other parameters). Your handler should return a 0 in order
  1158. to continue, or a 1 if you wish to end the requester. (You can check that
  1159. your custom handler ended the requester if the FileIO's Errno = ERR_APPGADG).
  1160. The only two requester gadgets that the library no longer controls are the CANCEL
  1161. and OK gadgets. Control of these two is passed to your custom handler. These
  1162. two gadgets have IDs of 32672 and 32673 respectively. If you receive either
  1163. of these IDs, you should return a 1. On the other hand, you could simply
  1164. cause these gadgets to be ignored by returning a 0. In any event, your
  1165. handler will have to return a 1 eventually in order to exit the requester,
  1166. or the user would have to type the Filename in the Filename string Gadget.
  1167. Do not use gadget IDs between 32672 to 32682 as these are reserved by the
  1168. library.
  1169.   For MOUSEMOVE, the events are "collected" (i.e. you only receive one event
  1170. when the user stops moving the mouse). Also, you won't receive MOUSEMOVE when
  1171. the user is operating the requester's scroll (prop) gadget. Your handler
  1172. doesn't need a return value.
  1173.   For RAWKEY, you won't receive any function keys. No return value is needed.
  1174.  
  1175.  The requester calls your handler with the following items in these
  1176. registers:
  1177.  
  1178.    a2 - the address of your FileIO
  1179.    a3 - the address of the window in which the requester is open
  1180.    a4 - the IAddress of the event (not valid for REQSET or DISKINSERTED)
  1181.    d6 - MouseX position (for RAWKEY handler, this is the Code instead)
  1182.    d7 - MouseY position (for RAWKEY handler, this is the Qualifier)
  1183.    d2 - Seconds
  1184.    d5 - Micros
  1185.    d0 - for GADGETUP and DOWN only, the gadgetID (need not be saved)
  1186.  
  1187.  You MUST save these registers if you plan on altering them.
  1188.     If your handler is written in C (yech!), I've provided a mechanism for
  1189. receiving these parameters passed on the stack like all good, inefficient C
  1190. programs should. Let's face it, C just doesn't have enough power to do the
  1191. sophisticated, efficient things that we do in assembly. But if you'd like to
  1192. fool yourself into thinking otherwise, I've tried to accomodate your
  1193. delusions. After filling in the HandlerBlock's pointers to the desired
  1194. routines, you must call SetFileIOHandlers(HandlerBlock). This routine
  1195. will see to it that your handler receives the following parameters except
  1196. where previously noted.
  1197.  
  1198.  yourHandler(IAddress,Window,FileIO,MouseY,MouseX,Micros,Seconds,GadgID)
  1199.  
  1200.   Unfortunately, unlike the assembly implementation, if you want to have
  1201. different FileIO's with unique custom handler routines, you'll have to
  1202. call SetFileIOHandlers() before each call to DoFileIO(). Hey, you're writing
  1203. in C, so you should be used to giving up some flexibility.
  1204.   If you're using Manx small data model, you'll probably have to call geta4
  1205. or savea4 (whatever). a4 will definitely not have the base of your program's
  1206. data section. These are the types of problems you should expect if you allow
  1207. a C compiler to determine 68000 register usage. Also, since register a6 is
  1208. "reserved" for library base vectoring on the Amiga, the C interface to the
  1209. library does not save this register. If your compiled program crashes because
  1210. of this, its time to buy a better compiler, or perhaps solve these headaches
  1211. once and for all with an assembler.
  1212.  
  1213. struct HandlerBlock {
  1214.    APTR  StartUpCode;       /* Called when the requester first opens */
  1215.    APTR  DiskInsertedCode;  /* Called whenever a disk is inserted */
  1216.    APTR  GadgetCode;        /* Called whenever a gadget UP or DOWN */
  1217.    APTR  KeyCode;           /* Called whenever a rawkey occurs */
  1218.    APTR  MouseMoveCode;     /* Called when the mouse is moved */
  1219.    };
  1220.  
  1221. assembly:
  1222.   dc.l AddrOfStartCode
  1223.   dc.l AddrOfDiskInsertCode
  1224.   dc.l AddrOfGadgetCode
  1225.   dc.l AddrOfRawkeyCode
  1226.   dc.l AddrOfMouseMoveCode
  1227.  
  1228.    Please note that if you should you DoFileIO() as opposed to DoFileIOWindow()
  1229. if using custom handlers.
  1230.  
  1231. =============================================================================
  1232. === TECHNICAL REFERENCE =====================================================
  1233. =============================================================================
  1234.  
  1235. The FileIO files include:
  1236.  
  1237.    requester.library      the actual library (slightly < 10K in size)
  1238.    manual                 The documentation. You've obviously found it.
  1239.    FileIO.h               includes for an C application using the library
  1240.    FileInterface.asm      glue routines for a C application to use the
  1241.                           library. (poot) Expects all integers passed 32bit
  1242.    FileIO.i               assembly programmer's include file
  1243.    main.c                 an application in C
  1244.    CustomList.c           an C demo using SPECIAL_REQ
  1245.    Test.asm               an application in assembly
  1246.    CustomList.asm         an asm application using SPECIAL_REQ
  1247.    StartUp.asm            the startup code for the assembly examples
  1248.    TestFileIO             an executable of the assembly application
  1249.    MakeTest               execute this script file to make the asm example
  1250.    BasicFileIO            an AmigaBasic application (do you believe me now?)
  1251.    BasicString            an AmigaBasic demo of SPECIAL_REQ
  1252.    requester.bmap         the bmap file for AmigaBasic
  1253.    requester_lib.fd       the fd file used to make the bmap file
  1254.    CopyLib                a utility to copy libraries to a boot disk
  1255.  
  1256. ================= USING THE AMIGA PROGRAMMER'S SUITE =======================
  1257.  The following is the message that appeared with RJ Mical's ProSuite code
  1258. on Fred Fish Disc #107. That version of FileIO was not a library. It was a
  1259. C code module that needed to be compiled and linked with your application.
  1260. At this point, the code for this library is significantly different than
  1261. the original, and quite incompatible with R.J's Includes and Defines. Also,
  1262. there are differences in both functionality and features. But R.J. started
  1263. the ball rolling so....
  1264.  
  1265. The Amiga Programmer's Suite Book 1 is copyrighted but freely distributable.
  1266. All copyright notices and all file headers must be retained intact.
  1267. The Amiga Programmer's Suite Book 1 may be compiled and assembled, and the 
  1268. resultant object code may be included in any software product.  However, no 
  1269. portion of the source listings or documentation of the Amiga Programmer's 
  1270. Suite Book 1 may be distributed or sold for profit or in a for-profit
  1271. product without the written authorization of the author, RJ Mical.
  1272.  
  1273. If you use the Amiga Programmer's Suite, I wouldn't mind if you gave me 
  1274. some mention somewhere.
  1275. Good luck!  Program hard, program well.    -RJ Mical
  1276.  
  1277. Make lots of money and become a arrogant, self-serving pain-in-the-ass.
  1278. -Jeff Glatt (my personal philosophy is a bit more philanthropic than RJ's)
  1279.  
  1280. === APPENDIX A:  FileIO Function Calls ======================================
  1281.  
  1282. CONTENTS:
  1283.    GetFullPathname()
  1284.    GetFileIO()
  1285.    DoFileIO()        ;only 1 task at a time
  1286.    DoFileIOWindow()  ;only 1 task at a time
  1287.    ReleaseFileIO()
  1288.    SetWaitPointer()
  1289.    ResetBuffer()
  1290.    AutoMessage()
  1291.    AutoFileMessage()
  1292.    AutoPrompt3()
  1293.    UserEntry()
  1294.    PromptUserEntry()
  1295.    TypeFilename()
  1296.    GetRawkey()
  1297.    DecodeRawkey()
  1298.    ParseString()
  1299.    NewEntryList()
  1300.    AddEntry()
  1301.  
  1302. *********************** GetFullPathname() *********************
  1303.  
  1304. NAME
  1305.     GetFullPathname  --  Build a file pathname using a FileIO struct
  1306.  
  1307.  
  1308. SYNOPSIS
  1309.     Buffer = GetFullPathname(FileIO, Buffer);
  1310.      d0                       a0       a1
  1311.  
  1312. FUNCTION
  1313.     Builds the text for a pathname using the FileName[], DrawerName[] and
  1314.     DiskName[] fields of the specified FileIO structure after the structure
  1315.     has been used in a successful call to DoFileIO(), DoFileIOWindow(), or
  1316.     TypeFilename(). Writes the text into the Buffer. 
  1317.  
  1318.  
  1319. INPUTS
  1320.     FileIO = the address of a FileIO structure
  1321.  
  1322.     Buffer = address of the buffer to receive the file pathname
  1323.  
  1324.  
  1325. RESULT
  1326.     The address of the passed buffer. Also, for assembly programmers the
  1327.     address of the terminating NULL is in a1 so you can quickly determine
  1328.     the string length by subtracting d0 from a1 with the result in a1.
  1329.  
  1330.  
  1331. SEE ALSO
  1332.     DoFileIO()
  1333.  
  1334. ********************* GetFileIO() ************************
  1335.  
  1336. NAME
  1337.     GetFileIO  --  Allocate and initialize a FileIO structure
  1338.  
  1339.  
  1340. SYNOPSIS
  1341.     struct FileIO *GetFileIO();
  1342.  
  1343.  
  1344. FUNCTION
  1345.     Allocates and initializes a FileIO structure for use with
  1346.     calls to DoFileIO(), DoFileIOWindow(), TypeFileName(), PromptUserEntry().
  1347.  
  1348.     You may want to further initialize the structure before calling these
  1349.     routines. At least the FileIO's Buffer, DrawMode, PenA, and PenB fields
  1350.     should be initialized. Instead of allocating a FileIO via this routine,
  1351.     you may declare one globally or statically as long as all fields are
  1352.     initialized to zero or an approprite value.
  1353.  
  1354.     When you're done with the structure, call ReleaseFileIO() regardless of
  1355.     whether it was allocated or declared to free up resources.
  1356.  
  1357. INPUTS
  1358.     None
  1359.  
  1360. RESULT
  1361.     If all goes well, returns the address of a FileIO structure.
  1362.     If anything goes wrong (out of memory), returns NULL.
  1363.  
  1364. BUGS
  1365.     None known
  1366.  
  1367.  
  1368. SEE ALSO
  1369.     DoFileIO(), DoFileIOWindow, ReleaseFileIO()
  1370.  
  1371.  
  1372. *********************** DoFileIO() **********************************
  1373.  
  1374. NAME
  1375.     DoFileIO  --  Gets a file name for input/output from the user
  1376.     DoFileIOWindow() -- The same, but opens a window for the requester.
  1377.  
  1378. SYNOPSIS
  1379.     ULONG address = DoFileIO(fileio, window);
  1380.             d0                a0      a1
  1381.     ULONG address = DoFileIOWindow(fileio, screen);
  1382.             d0                      a0      a1
  1383.  
  1384. FUNCTION
  1385.     This routine creates a filename requester which allows the user to browse
  1386.     through the AmigaDOS filesystem and select one of the filenames found
  1387.     there.
  1388.  
  1389.     The fileio argument is a pointer to a FileIO structure, which is allo-
  1390.     cated and initialized via a call to GetFileIO(), or declared in your
  1391.     application.
  1392.     You may preset the FileIO parameters before calling this routine, 
  1393.     or you may leave them set at their default values.  See the FileIO
  1394.     documentation and include files for complete details.
  1395.  
  1396.     The window argument is the pointer to the window structure returned
  1397.     by a call to Intuition's OpenWindow() function.  As this routine
  1398.     opens a requester and requesters open in windows, you must have
  1399.     already opened a window before calling this routine, even if it's
  1400.     a window opened for no other purpose than to call this routine.
  1401.     DoFileIOWindow() is provided to circumvent this problem. It simply opens
  1402.     a window on the passed screen before calling DoFileIO, and closes it
  1403.     upon exit. By setting screen to NULL, the window opens on the WorkBench
  1404.     screen. Also, you might use DoFileIOWindow if you wanted a requester
  1405.     that could be moved or depth arranged by the user in an existing screen.
  1406.     The title that appears in the window will be gotten from the address in
  1407.     the FileIO's Title field.
  1408.  
  1409.     You must initialize the FileIO's Buffer field to hold the address of a
  1410.     buffer where the full pathname string (i.e. disk:drawer.../filename) will
  1411.     be constructed. The size should be no less than 202 bytes. Also, the
  1412.     FileIO's DrawMode, PenA, and PenB fields should be set to the values
  1413.     you want restored when the requester closes.
  1414.  
  1415.     This routine returns a 0 if DoFileIOWindow's window couldn't open, a -1
  1416.     if the user selected CANCEL, or the address of the FileIO's Buffer if
  1417.     all went well and the user selected a filename. The full path name will
  1418.     have been constructed in the buffer. The filename itself will have
  1419.     all leading and trailing blanks removed (in case the user typed in a
  1420.     filename with extraneous spaces) and stored in the FileIO's FileName[].
  1421.     Likewise, the disk and drawer names can be found in the text
  1422.     fields DiskName[] and DrawerName[] of the FileIO. You can always call
  1423.     GetFullPathname() to build the pathname from the separate fields of the
  1424.     FileIO.
  1425.  
  1426.     There's a *lot* more to be said about this function.  Please 
  1427.     read the documentation.
  1428.  
  1429.     NOTE:  This routine is not re-entrant.  What this means is that if some
  1430.     other task is calling DoFileIO() or DoFileIOWindow(), this routine
  1431.     will automatically call TypeFilename() for the 2nd application.
  1432.  
  1433. INPUTS (for DoFileIO)
  1434.     fileio = pointer to a FileIO structure, as allocated
  1435.         via a call to GetFileIO()
  1436.  
  1437.     window = pointer to a Window structure, as created via a call
  1438.         to Intuition's OpenWindow()
  1439.  
  1440. RESULT
  1441.     0 if an error in opening DoFileIOWindow() window. You will not get this
  1442.       error for DoFileIO()
  1443.    -1 if the user selected CANCEL
  1444.     the address of the Buffer if all went well and a file was selected. Also
  1445.     for assembly programmers the end of the string is in a1 like GetFullPathname.
  1446.  
  1447. BUGS
  1448.     None known
  1449.  
  1450. SEE ALSO
  1451.     GetFullPathname(), GetFileIO(), ReleaseFileIO()
  1452.  
  1453.  
  1454. ************************* ReleaseFileIO() **************************
  1455.  
  1456. NAME
  1457.     ReleaseFileIO  --  Release the FileIO structure and all local memory
  1458.  
  1459.  
  1460. SYNOPSIS
  1461.     ReleaseFileIO(fileio);
  1462.                     a1
  1463.  
  1464. FUNCTION
  1465.     Releases the FileIO structure by freeing all local memory attached
  1466.     to the structure and then freeing the structure itself if it is an
  1467.     ALLOCATED_FILEIO (i.e. not pre-initialized in your application).
  1468.     Restores the directory that was established when the FileIO was first
  1469.     sent to DoFileIO() or DoFileIOWindow(). (You should not unlock the
  1470.     initial dir that is contained in the FileIO's originalLock field.)
  1471.  
  1472. INPUTS
  1473.     fileio = the address of a FileIO structure
  1474.  
  1475.  
  1476. RESULT
  1477.     None
  1478.  
  1479.  
  1480. SEE ALSO
  1481.     GetFileIO()
  1482.  
  1483. ************************** SetWaitPointer() *************************
  1484.  
  1485. NAME
  1486.     SetWaitPointer - Sets the zzz cloud pointer in the passed window.
  1487.  
  1488.  
  1489. SYNOPSIS
  1490.     SetWaitPointer(window);
  1491.                     a0
  1492.  
  1493. FUNCTION
  1494.     If you want to have a wait pointer appear in a window, you can use this
  1495.     function which already has set up the pointer data in CHIP mem. Then
  1496.     when you want to restore the pointer, call Intuition's ClearPointer().
  1497.  
  1498. INPUTS
  1499.     window = the address of a window structure
  1500.  
  1501.  
  1502. RESULT
  1503.     None
  1504.  
  1505.  
  1506. ************************* AutoMessage() ************************
  1507.  
  1508. NAME
  1509.     Automessage - an easy implementation of an AutoRequester
  1510.  
  1511.  
  1512. SYNOPSIS
  1513.      AutoMessage(message, window);
  1514.                    d0       a0
  1515.      AutoMessageLen(message, window, length);
  1516.                       d0       a0      d1
  1517.  
  1518. FUNCTION
  1519.     This displays the passed string (whose address is in d0) in a simple
  1520.     AutoRequester. It manages the dimensions (automatically sizes to the
  1521.     passed message) and the IntuiText structure for you. Use AutoMessageLen
  1522.     if you know the length of the string to be displayed.
  1523.  
  1524. INPUTS
  1525.     window = the address of a window structure
  1526.     message = address of the string to be displayed
  1527.  
  1528. RESULT
  1529.     None
  1530.  
  1531. ************************* AutoFileMessage() ****************************
  1532.  
  1533. NAME
  1534.     AutoFilemessage - AutoMessage with preset strings to choose from
  1535.  
  1536.  
  1537. SYNOPSIS
  1538.     BOOL AutoFileMessage(messagenumber, window);
  1539.                             d1             a0
  1540.  
  1541. FUNCTION
  1542.     The requester library has several messages it uses for internal use.
  1543.     You can have one of these messages displayed just by passing the number
  1544.     of the message you want. See Include file for available messages.
  1545.     Some of the messages have two responses "YES" and "OK". Others have just
  1546.     the "OK".
  1547.  
  1548. INPUTS
  1549.     window = the address of a window structure
  1550.     messagenumber = number of the string to be displayed
  1551.  
  1552. RESULT
  1553.     Returns FALSE (d0 = 0) if the user selects "NO" or TRUE (d0 = 1) if the
  1554.     user selects "OK".
  1555.  
  1556. ************************ AutoPrompt3() **************************
  1557.  
  1558. NAME
  1559.     AutoPrompt3 - AutoRequester with up to 3 lines of Text
  1560.  
  1561.  
  1562. SYNOPSIS
  1563.     BOOL AutoPrompt3(message1, message2, message3, window);
  1564.                         a1        a2       a3        a0
  1565.  
  1566. FUNCTION
  1567.     Displays up to 3 passed strings in an autorequester. Automatically
  1568.     dimensions the requester to the size of the longest string, and
  1569.     positions the other strings for a symmetrical display. Returns with
  1570.     user's response to "YES" or "NO". You can also display only 2 or even
  1571.     1 string if you pass NULL for the other messages.
  1572.  
  1573. INPUTS
  1574.     window = the address of a window structure
  1575.     message1 = address of the top string to be displayed
  1576.     message2 = address of the 2nd string to be displayed or NULL if none
  1577.     message3 = address of the 3nd string to be displayed or NULL if none
  1578.  
  1579. RESULT
  1580.     Returns FALSE (d0 = 0) if the user selects "NO" or TRUE (d0 = 1) if the
  1581.     user selects "YES".
  1582.  
  1583. ************************ ResetBuffer() *********************************
  1584.  
  1585. NAME
  1586.     ResetBuffer - Resets the cursor within a StringInfo's buffer to the
  1587.                   first position. Also, can NULL out the buffer itself and
  1588.                   reset the number of chars to 0.
  1589.  
  1590.  
  1591. SYNOPSIS
  1592.     ResetBuffer(stringinfo, resetFlag);
  1593.                    a0           d0
  1594.  
  1595. FUNCTION
  1596.     If you have a String gadget whose cursor you'd like to set back at the
  1597.     first position, you can use this function. Also, if resetFlag is TRUE
  1598.     (1) then the gadget's buffer will be NULLED. You must refresh the gadget
  1599.     yourself after this call.
  1600.  
  1601. INPUTS
  1602.     stringinfo = the address of a StringInfo structure
  1603.     resetFlag = whether to NULL or not
  1604.  
  1605. RESULT
  1606.     NONE
  1607.  
  1608. ;********************* TypeFilename ***************************
  1609.  
  1610. NAME
  1611.     TypeFilename - Uses the window's titlebar to obtain the path name instead
  1612.                    of the file requester (an alternative). Displays the prompt
  1613.                    "Filename >"
  1614.  
  1615. SYNOPSIS
  1616.     buffer =TypeFilename(FileIO, Window);
  1617.                             a0     a1
  1618.  
  1619. FUNCTION
  1620.    If you really don't like the requester, and would prefer to have the
  1621.    user type in the full path via the window's title bar, then use this.
  1622.    Also, you might use this within a save routine so that the user has to
  1623.    deliberately type his choice. The pathname contained within the FileIO's
  1624.    Disk, Drawer, and Filename fields is what is initially presented to the
  1625.    user. This routine is automatically called if an application tries to
  1626.    call DoFileIO() or DoFileIOWindow() when another task is displaying the
  1627.    FileIO requester. Also called if there is not enough mem to open/display
  1628.    the requester. This routine sets up the FileIO's Disk, Drawer, Filename,
  1629.    FileSize, and FreeBytes fields in the same manner as DoFileIO so that
  1630.    you can interpret the results in exactly the same manner.
  1631.  
  1632. INPUTS
  1633.     Window = the address of a window
  1634.     FileIO = the FileIO structure
  1635.  
  1636. RESULT
  1637.   Returns the address of the FileIO's Buffer or a -1 if the user bailed
  1638.   out without entering anything. An ESC will return -1, but will store an
  1639.   ESC char ($1B) and then NULL char in the buffer.
  1640.  
  1641.  
  1642. ;*************************** UserEntry  ***************************
  1643.  
  1644. NAME
  1645.     UserEntry - Uses the window's titlebar to obtain user input.
  1646.  
  1647. SYNOPSIS
  1648.     buffer = UserEntry(charlimit, initBuffer, FileIO, Window);
  1649.                            d0         a1        a2      a3
  1650.  
  1651. FUNCTION
  1652.    This clears the window's titlebar, displays a cursor, and allows the user
  1653.    to type in chars up to the limit, or until CR or ESC is pressed. The NULL
  1654.    terminated result is placed in the FileIO's Buffer. When the charlimit is
  1655.    reached, the routine automatically terminates.  You must set the FileIO's
  1656.    PenA, PenB, and DrawMode fields so that these may be restored by the lib
  1657.    when the function is finished.
  1658.    The initBuffer string is what is presented to the user (and what he may
  1659.    edit). The passed window must have RAWKEY IDCMP set, and the FileIO's
  1660.    RawCode field set to 0 in order to use the default decoding routine,
  1661.    GetRawkey(). Otherwise, decoding will be redirected to the routine specified
  1662.    in the FileIO's RawCode field. (Maybe you want VANILLAKEY instead. Or
  1663.    maybe you also want to handle other IDCMP events while "inside" of UserEntry.
  1664.    GetRawkey disposes of all but RAWKEY events. Or maybe you've set up your
  1665.    own custom IDCMP port and RAW handling routine.) Regardless, your RawCode
  1666.    routine must go to the window's IDCMP port to get a message or wait if
  1667.    there is no message. It should handle all IDCMP messages except RAWKEY or
  1668.    VANILLAKEY. If one of these messages, exit with an UWORD representing the
  1669.    character as follows:
  1670.    $20 to $7F for ascii chars, $DF for delete, $08 for BACKSPACE, $0D for
  1671.    RETURN, $1B for ESCAPE, $010C for LEFT Cursor, $010D for Right Cursor,
  1672.    $020C for SHIFT-LEFT Cursor, and $020D for SHIFT-RIGHT Cursor.
  1673.    UserEntry will continue calling your RawCode for each char, and terminate
  1674.    upon receiving an $0D or $1B, or reaching the charlimit.
  1675.    Since the titlebar can hold approx 70 chars between the CLOSEGADGET and
  1676.    FRONT/BACK, the FileIO's Buffer might be set to 70 bytes. It must be at
  1677.    least as big as charlimit. If the charlimit is greater than 70 bytes, the
  1678.    user can still enter chars, but he will not see them. Upon return, your
  1679.    window's title is restored.
  1680.  
  1681. INPUTS
  1682.     Window = the address of a window
  1683.     FileIO = the FileIO structure
  1684.     charlimit = the number of characters to accept from the user
  1685.     initBuffer = the NULL-terminated string to initialize the FileIO's
  1686.              buffer to, or NULL if no initialization desired
  1687.  
  1688. RESULT
  1689.   Returns the address of the FileIO's Buffer or a 0 if the user bailed
  1690.   out without entering anything. An ESC will return 0, but will store an
  1691.   ESC char ($1B) and then NULL char in the buffer.
  1692.  
  1693. ;******************** PromptUserEntry  ***************************
  1694.  
  1695. NAME
  1696.     PromptUserEntry - Uses the window's titlebar to obtain user input.
  1697.  
  1698. SYNOPSIS
  1699.     buffer = PromptUserEntry(charlimit,prompt,initBuffer,FileIO,Window);
  1700.                                  d0      a0      a1        a2     a3
  1701.  
  1702. FUNCTION
  1703.    This works just like UserEntry except that it first displays the
  1704.    passed prompt string in the titlebar. The FileIO's Buffer should always
  1705.    be greater than the number of chars in the prompt plus charlimit.
  1706.  
  1707. INPUTS
  1708.     Window = the address of a window
  1709.     FileIO = the FileIO structure
  1710.     charlimit = the number of characters to accept from the user
  1711.     buffer = the buffer where the user's input is placed
  1712.     prompt = NULL-terminated prompt to display
  1713.     initBuffer = the NULL-terminated string to initialize the FileIO's
  1714.              buffer to, or 0 if no initialization desired
  1715.  
  1716. RESULT
  1717.   Returns the address of the FileIO's Buffer or a 0 if the user bailed
  1718.   out without entering anything. An ESC will return 0, but will store an
  1719.   ESC char ($1B) and NULL char in the buffer.
  1720.  
  1721. ******************* SetTitle() ********************************
  1722.  
  1723. NAME
  1724.    SetTitle - Uses the window's titlebar to display 1 or 2 strings.
  1725.  
  1726. SYNOPSIS
  1727.     SetTitle(String1,String2,FileIO,Window);
  1728.                a0      a1      a2     a3
  1729.  
  1730. INPUTS
  1731.     Window = the address of a window
  1732.     FileIO = the FileIO structure
  1733.     String1 = the NULL-terminated string to the left
  1734.     String2 = NULL-terminated string placed to the right of String1. If you
  1735.               pass a zero instead, no 2nd string displayed.
  1736.  
  1737. FUNCTION
  1738.   This will display the 2 strings in the window's titlebar (saving the
  1739.   initial title to the FileIO's Title field), and return immediately with
  1740.   the strings still displayed. Subsequent calls can be made to display
  1741.   different strings, but when ResetTitle() is finally called, the initial
  1742.   titlebar is restored. This routine is useful for displaying error msgs to
  1743.   the user without halting program execution (like a requester does), and
  1744.   allows the msg to remain visible for as long as it is needed. Furthermore,
  1745.   it doesn't require that the user respond to it. This function makes temp-
  1746.   orary use of the FileIO's Buffer, so you must supply a buffer whose address
  1747.   is stored at the FileIO Buffer field. This buffer must be large enough to
  1748.   contain both Strings.
  1749.  
  1750. ******************* ResetTitle() ********************************
  1751.  
  1752. NAME
  1753.    ResetTitle - Restores the window's titlebar after calls to SetTitle
  1754.                 (if any calls were made at all)
  1755.  
  1756. SYNOPSIS
  1757.     ResetTitle(FileIO,Window);
  1758.                  a2     a3
  1759.  
  1760. INPUTS
  1761.     Window = the address of a window
  1762.     FileIO = the FileIO structure
  1763.  
  1764. FUNCTION
  1765.     Resets the initial title (stored in FileIO's Title field) if it detects
  1766.     that any calls were made to SetTitle. Otherwise, it does nothing.
  1767.  
  1768. *********************** ParseString() *******************************
  1769.  
  1770. NAME
  1771.   ParseString - Separate a path string into separate components
  1772.  
  1773. SYNOPSIS
  1774.   ParseString(FileIO,String)
  1775.                 a0     a1
  1776.  
  1777. INPUTS
  1778.    The FileIO structure
  1779.    The address of the NULL-terminated path
  1780.  
  1781. FUNCTION
  1782.    This takes the NULL-terminated path as it would be typed on a CLI line
  1783.  
  1784.    Diskname:TopDrawer/....etc.../BottomDrawer/Filename
  1785.  
  1786.    and parses it for "weird" typos or non-existant disk or drawer names.
  1787.    Of course, there may not be any Disk or Drawer names. It then copies the
  1788.    individual components of the Disk, drawer, and filename to the FileIO's
  1789.    respective buffers, and sets the FILEIO_FILESIZE and FILEIO_FREEBYTES
  1790.    fields accordingly. (i.e. If the path turns out to be a drawer or disk
  1791.    only, then FileIO's Filename is NULLED and FileSize = 0. If a non-existant
  1792.    file, it copies the Filename to FileIO, but FileSize = 0. If it is a
  1793.    loadable file, it copies the Filename and sets FileSize accordingly.)
  1794.    The parsed result is placed into the FileIO's Buffer (cannot be the same
  1795.    buffer as the passed string).
  1796.       This is useful for processing the initial argv argument passed to
  1797.    _main for the StartUp code. It will initialize the FileIO buffers to
  1798.    this passed name, and set-up the FileSize and Filename buffer so that
  1799.    it can be determined what kind of object this is. Also, it makes it
  1800.    possible to use the same load routine for the initial passed argv as
  1801.    you would for DoFileIO() or TypeFilename(). For Basic programmer's this
  1802.    can be used to set up the FileIO based upon a string gotten via an Input
  1803.    statement.
  1804.  
  1805. ******************* AddEntry(), NewEntryList() ***********************
  1806.  
  1807. NAME
  1808.   AddEntry - For adding a string to a list to be displayed by the FileIO
  1809.  
  1810. SYNOPSIS
  1811.   AddEntry(ID_num, String, FileIO)
  1812.               d1     a0     a1
  1813.  
  1814. INPUTS
  1815.    The FileIO structure
  1816.    The address of the NULL-terminated string to be added
  1817.    A ULONG (or LONG if you define it that way) that is associated with the
  1818.      string
  1819.  
  1820. FUNCTION
  1821.    When the SPECIAL_REQ flag of the FileIO is set, then DoFileIO() and DoFile-
  1822. IOWindow() no longer do disk operations. Instead, the FileIO operates on a
  1823. list of strings which you create via AddEntry().
  1824.    NewEntryList() deletes any list associated with the FileIO.
  1825.    This returns the same values as DoFileIOWindow() plus a -2 if some other
  1826. task is using the FileIO requester.
  1827.