home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / BASIC / BAS_SUB.ZIP / FCBREAD.BAS < prev    next >
Encoding:
BASIC Source File  |  1985-04-19  |  2.5 KB  |  46 lines

  1. 10 DEF SEG=&H2100  'Dependent upon your memory
  2. 20 '   This sample program serves as both an example and the documentation
  3. 30 '   for the FCBREAD.BSV routine that will read the directory of a
  4. 40 '   disk and present the matching file name back to the BASIC program.
  5. 50 '   Also available to the program is the directory information that
  6. 60 '   contains the size and time/date information. This routine is
  7. 70 '   faster than OPENing the file since it does not incur that overhead.
  8. 80 '   Also the user can present an arbitrary string to match on.
  9. 90 '
  10. 100 '   To use, BLOAD the routine into any available free memory. It
  11. 110 '   has 2 entry points (INIT and GETNEXT). INIT (offset 2) is used
  12. 120 '   to define the disk drive (0=default, 1=A, 2=B, ....) and the
  13. 130 '   pattern to be used to match on. The pattern MUST BE a string of
  14. 140 '   length 11; the first 8 are the filename and the last 3 are the
  15. 150 '   extension. A "?" is used to match any character. For example to
  16. 160 '   get all the BASIC files on the disk, "????????BAS" would be used
  17. 170 '   as the input parameter. After INIT has been called, calls to
  18. 180 '   GETNEXT (offset 5) are made to retrieve matching file names.
  19. 190 '   The two parameters are the string in which the match is returned
  20. 200 '   (which must be of length 14) and an INTEGER (..%) return value.
  21. 210 '   If the status return is <0, no more matched have been found. If
  22. 220 '   status >=0, it is the FILE ATTRIBUTE (as defined in the DOS Disk
  23. 230 '   Directory).
  24. 240 '
  25. 250 '   The INTEGER value at offsets 0,1 in the routine are the offset
  26. 260 '   to the directory entry for the file. For example, to obtain the
  27. 270 '   DATE information of the file, use the following statements:
  28. 280 '        B% = PEEK(0)+PEEK(1)*256   ' Get offset value
  29. 290 '        FDATE = PEEK(B%+26)*256 + PEEK(B%+25)
  30. 300 '
  31. 310 '   The offsets into the directory entry (25, 26 in this case) are
  32. 320 '   defined in the DOS manual.
  33. 330 '
  34. 340 '   The example program will print all the file names on the current
  35. 350 '   Directory plus their attributes.
  36. 360 BLOAD "fcbread.bsv",0
  37. 370 INIT%=2:GETNEXT%=5
  38. 380 FILENAME$="???????????"
  39. 390 DISK%=1:CALL INIT%(DISK%,FILENAME$)
  40. 400 FILENAME$=SPACE$(14):CALL GETNEXT%(FILENAME$,STATUS%)
  41. 410 PRINT FILENAME$,STATUS%
  42. 420 IF STATUS%>=0 THEN GOTO 400
  43. ME$)
  44. 400 FILENAME$=SPACE$(14):CALL GETNEXT%(FILENAME$,STATUS%)
  45. 410 PRINT FILENAME$,STATUS%
  46. 420 IF