home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / S12334.ZIP / DEMO.BAS next >
BASIC Source File  |  1989-03-23  |  2KB  |  60 lines

  1. '***** DEMO.BAS - demonstrates the BASIC and assembler OS/2 routines
  2. '
  3. 'This routine can call either assembly language or BASIC modules.
  4. 'Include the statements marked "*** BASIC only" if using BASIC modules,
  5. 'and those marked "*** Assembly only" if using assembly language routines.
  6. '
  7.  
  8. DEFINT A-Z
  9.  
  10. DECLARE FUNCTION FileCount%(FileSpec$)
  11. DECLARE FUNCTION GetDir$(Drive$)
  12. DECLARE FUNCTION GetDrive%()
  13.  
  14. DECLARE SUB ReadNames(Spec$, Array$())      '*** BASIC only
  15. DECLARE SUB ReadNames(Spec$, BYVAL Element) '*** Assembly only
  16. DECLARE SUB SetDrive(Drive$)
  17.  
  18. INPUT "Enter a file specification or press Enter for *.*:  ", Spec$
  19.  
  20. IF (Spec$ = "") THEN              'Pressed Enter, use *.*
  21.     Spec$ = "*.*"
  22. ENDIF
  23.  
  24. Spec$ = Spec$ + CHR$(0)                   '*** Assembly only -- append NULL
  25.  
  26. Count = FileCount%(Spec$)                 'count the number of matching files
  27.  
  28. IF (Count > 0) THEN
  29.  
  30.     DIM Array$(1 TO Count)                'make an array to hold them
  31.  
  32.     FOR X = 1 TO Count                    '*** Assembly only
  33.         Array$(X) = SPACE$(12)          'Make array 12 characters long
  34.     NEXT
  35.  
  36.     ReadNames Spec$, Array$()             '*** BASIC only
  37.     ReadNames Spec$, VARPTR(Array$(1))    '*** Assembly only
  38.  
  39.     FOR X = 1 TO Count                    'print the filenames
  40.         PRINT Array$(X),
  41.     NEXT
  42.  
  43. ELSE
  44.  
  45.     PRINT "No files found"          'No matching files
  46.  
  47. ENDIF
  48.  
  49. SaveDrive$ = CHR$(GetDrive%)              'save the current drive
  50. PRINT
  51. PRINT "The current drive is " SaveDrive$          'print it
  52. PRINT "and its directory is " GetDir$(SaveDrive$) 'print current directory
  53. INPUT "Enter a new drive to move to: ", NewDrive$ 'prompt for a new drive
  54. SetDrive NewDrive$                        'set it
  55.  
  56. PRINT "The current drive is: " CHR$(GetDrive%)     'print the new drive
  57.  
  58. PRINT "Moving back to "SaveDrive$               'inform user
  59. SetDrive SaveDrive$                                'restore original drive
  60.