home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / magazine / ins_msb / 9004 / fileopen.bas < prev    next >
BASIC Source File  |  1990-04-01  |  1KB  |  49 lines

  1. DECLARE FUNCTION SetMaxFiles% (NbrFiles AS INTEGER)
  2.  
  3. 'PROGRAM: FILEOPEN.BAS
  4.  
  5. 'PURPOSE: Demonstrate process to open more than
  6. '         15 files in QuickBASIC and PDS
  7.  
  8. 'Use the QBX.BI include file in the INCLUDE
  9. 'metacommand if you are using BASIC version 7.0
  10. 'else use QB.BI if you use QuickBASIC
  11.  
  12. '$INCLUDE: 'QBX.BI'
  13.  
  14. CLS : PRINT "Opening 20 files"
  15.  
  16. 'Place a comment marker in front of next line 
  17. ' to see the program fail
  18.  
  19. ErCode% = SetMaxFiles%(25)
  20.  
  21. IF ErCode% THEN
  22.     PRINT "Error number "; ErCode%; " encountered."
  23.     STOP
  24. END IF
  25.  
  26. FOR I% = 1 TO 20
  27.   F$ = "TEST" + CHR$(I% + 64) + ".TMP"
  28.   PRINT "Opening file "; F$
  29.   OPEN "O", I%, F$
  30. NEXT I%
  31. CLOSE
  32. KILL "TEST*.TMP"  'Get rid of the test files
  33. END
  34.  
  35. FUNCTION SetMaxFiles% (NbrFiles AS INTEGER)
  36.  
  37. DIM InRegs AS RegType, OutRegs AS RegType
  38.  
  39. InRegs.AX = &H6700
  40. InRegs.BX = NbrFiles
  41.  
  42. SetMaxFiles = 0         'Initialize return value
  43.  
  44. CALL Interrupt(&H21, InRegs, OutRegs)
  45.  
  46. IF (OutRegs.Flags AND 1) = 1 THEN_
  47.    SetMaxFiles% = OutRegs.AX  'Error number
  48. END FUNCTION
  49.