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 / BasicUsers < prev    next >
Text File  |  1989-10-19  |  6KB  |  132 lines

  1.                          FOR BASIC PROGRAMMERS
  2.  
  3.   The file requester operates on a structure which I've called a FileIO struct.
  4. A structure is one block of memory which contains various "fields". A field
  5. is simply a portion (some bytes) of that block of memory. The FileIO struct-
  6. ure takes up 264 bytes of memory. These 264 bytes contain 29 fields. Some
  7. fields only take up 1 byte, others are 2 bytes wide (a WORD), or 4 bytes
  8. wide (a LONG). Certain other fields can be any number of bytes wide. These
  9. are STRINGS. Each field of a structure contains values (numbers). Sometimes
  10. these numbers form the address of some other structure. An address takes up
  11. 4 bytes (just like a LONG), but we'll call it APTR.
  12.   Unfortunately, AmigaBasic has no facility for manipulating structures as
  13. such. You cannot say, "Set the PenA field of my FileIO to the value 1." You
  14. must treat the FileIO as one block of memory, and its various fields as
  15. offsets from the beginning of that block of memory. The library routine
  16. GetFileIO() returns the start address of the FileIO memory block. This is
  17. what it looks like in memory.
  18.  
  19.   Field Name      Field Size       Offset from start
  20.  ------------    -------------    -------------------
  21.  
  22. The FileIO starts here:
  23.   LibFlags         1 BYTE                 0
  24.   Flags            1 BYTE                 1
  25.   FileName        30 BYTES (STRING)       2
  26.   DrawerName     132 BYTES (STRING)      32
  27.   DiskName        30 BYTES (STRING)     164
  28.   DOS lock         4 BYTES (APTR)       194
  29.   NameCount        2 BYTES (WORD)       198
  30.   NameStart        2 BYTES (WORD)       200
  31.   CurrentPick      2 BYTES (WORD)       202
  32.   FileKey          4 BYTES (APTR)       204
  33.   FileIOText       4 BYTES (APTR)       208
  34.   FileIORoutine    4 BYTES (APTR)       212
  35.  the next 2 fields are for WB pattern match (i.e. Icon files displayed only)
  36.   DiskObjectType   2 BYTES (WORD)       216
  37.   ToolTypes        4 BYTES (LONG)       218
  38.  the next 2 fields are for extention match
  39.   ExtStringAddr    4 BYTES (APTR)       222
  40.   ExtStringLen     2 BYTES (WORD)       226
  41.   CustomHandler    4 BYTES (APTR)       228
  42.  the next 2 fields are the XY where the requester will open up in the window
  43.   ReqXposition     2 BYTES (WORD)       232
  44.   ReqYposition     2 BYTES (WORD)       234
  45.   FreeDiskSpace    4 BYTES (LONG)       236
  46.   FileSize         4 BYTES (LONG)       240
  47.   WindowTitle      4 BYTES (APTR)       244
  48.   BufferAddress    4 BYTES (APTR)       248
  49.   RawkeyCode       4 BYTES (APTR)       252
  50.   OriginalLock     4 BYTES (APTR)       256
  51.   Error number     1 BYTE               260
  52.   DrawMode         1 BYTE               261
  53.   PenA             1 BYTE               262
  54.   PenB             1 BYTE               263
  55.  
  56.   If you add up the sizes of all 29 fields, you should get 264 bytes.
  57.  
  58.   Now, let's say that we called GetFileIO() as demonstrated in the example
  59. program, BasicFileIO. We stored the returned address in a variable called
  60. FileIO.
  61.   There are two AmigaBASIC commands that are used with structures, PEEK and
  62. POKE. If you want to change a field of the FileIO, you must POKE a value to
  63. it. If you want to know what value is already stored in a FileIO field, then
  64. you PEEK that field. For example, if we want to know what the FileIO's PenA
  65. field is, we PEEK that field as follows.
  66.  
  67.   VALUE = PEEK(FileIO+262)
  68.  
  69.   I had to add 262 to FileIO because the PenA field's offset is 262 (see
  70. above chart). Now VALUE is the number that was in the PenA field. If we want
  71. to change the number in the PenA field to 2, we must POKE the field like this:
  72.  
  73.   POKE  FileIO+262,2
  74.  
  75.   PEEK and POKE are used for fields that are only 1 BYTE in size (like the
  76. PenA, PenB, Flags, etc). For fields that are 2 BYTES (WORD) in size, you
  77. must use POKEW and PEEKW. For example, to change the ReqXposition to 50:
  78.  
  79.   POKEW FileIO+232,50
  80.  
  81.   Notice how I added the ReqXposition field's offset to FileIO.
  82.  
  83.   For LONG and APTR fields (4 BYTES in size), you must use PEEKL and POKEL.
  84. An APTR field is tricky because you can only put an address there. There are
  85. two BASIC commands for finding addresses of variables. If the variable is a
  86. string, use SADD. For all other types of variables, use VARPTR. For example,
  87. let's say we declared the following string.
  88.  
  89.   Title$ = "Hello"
  90.  
  91.   Now, let's set the FileIO's WindowTitle field to the address of our string.
  92. As you can see from the chart, the FileIO's WindowTitle field is APTR. In
  93. fact, this field holds the address of the title that is displayed in the
  94. window when the requester opens. Notice that this field's offset is 244.
  95.  
  96.   POKEL FileIO+244,SADD(Title$)
  97.  
  98.   For STRINGS (like the FileIO's Diskname), you must use PEEK or POKE to
  99. examine or alter EVERY SINGLE BYTE of the string. The Diskname is 30 BYTES
  100. and has an offset of 164 from the FileIO base. To copy the diskname to a
  101. a BASIC string, you must declare a string of 30 chars in length,
  102.  
  103.   DIM DiskName$(30)
  104.  
  105.   and PEEK all 30 bytes (starting at an offset of 164) to this BASIC string.
  106. See the example program for details.
  107.  
  108.   There is much more to be said about this topic. Please examine the commented
  109. code of the enclosed BASIC example. If the code seems completely alien to you,
  110. then you should buy a book on advanced AmigaBASIC programming. I can't recom-
  111. mend one as I didn't read any. Being an assembly programmer, I was able to
  112. ascertain how to use these BASIC commands by studying an example on the EXTRAS
  113. disk.
  114.  
  115.   There is one FileIO field that the example only briefly covers, the Flags
  116. field. Here are the values you should POKE to enable the following features.
  117. To enable several features simultaneously, just add up the value for each.
  118.  
  119. NO_CARE_REDRAW   = 1
  120. USE_DEVICE_NAMES = 2
  121. EXTENSION_MATCH  = 4
  122. DOUBLECLICK_OFF  = 8
  123. WBENCH_MATCH     = 16
  124. MATCH_OBJECTTYPE = 32
  125. MATCH_TOOLTYPE   = 64
  126. INFO_SUPPRESS    = 128
  127.  
  128.   Of course, read the enclosed Manual fully for a complete understanding of
  129. the library functions.
  130.  
  131.           Jeff Glatt
  132.