home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / WINER.ZIP / CHAP6-9.BAS < prev    next >
BASIC Source File  |  1993-06-01  |  2KB  |  75 lines

  1. '*********** CHAP6-9.BAS - shows how to open more than 15 files
  2.  
  3. 'Copyright (c) 1992 Ethan Winer
  4.  
  5. DEFINT A-Z
  6. DECLARE SUB INTERRUPT (IntNum, InRegs AS ANY, OutRegs AS ANY)
  7. DECLARE SUB MoreFiles (NumFiles)
  8. DECLARE FUNCTION DOSVer% ()
  9.  
  10. 'NOTE: DOS uses file handles 0 through 4 for its own use.  Therefore, when
  11. 'increasing the available number of files the extra five must be accounted
  12. 'for.  This is handled in the code where +5 is used in two places.  Also,
  13. 'DOS has to allocate memory to hold the additional file handle information,
  14. 'so that's why SETMEM is used in the MoreFiles subprogram.
  15.  
  16. TYPE RegType
  17.   AX     AS INTEGER
  18.   BX     AS INTEGER
  19.   CX     AS INTEGER
  20.   DX     AS INTEGER
  21.   BP     AS INTEGER
  22.   SI     AS INTEGER
  23.   DI     AS INTEGER
  24.   Flags  AS INTEGER
  25. END TYPE
  26. DIM SHARED InRegs AS RegType, OutRegs AS RegType
  27.  
  28. ComSpec$ = ENVIRON$("COMSPEC")
  29. BootDrive$ = LEFT$(ComSpec$, 2)
  30. OPEN BootDrive$ + "\CONFIG.SYS" FOR INPUT AS #1
  31.   DO WHILE NOT EOF(1)
  32.     LINE INPUT #1, Work$
  33.     Work$ = UCASE$(Work$)
  34.     IF LEFT$(Work$, 6) = "FILES=" THEN
  35.       FilesVal = VAL(MID$(Work$, 7))
  36.       EXIT DO
  37.     END IF
  38.   LOOP
  39. CLOSE
  40.  
  41. INPUT "How many files? ", NumFiles
  42. IF NumFiles + 5 > FilesVal THEN
  43.   PRINT "Increase the FILES= setting in CONFIG.SYS"
  44.   END
  45. END IF
  46.  
  47. IF DOSVer% >= 330 THEN
  48.   CALL MoreFiles(NumFiles)
  49. ELSE
  50.   PRINT "Sorry, DOS 3.3 or later is required."
  51. END IF
  52.  
  53. FOR X = 1 TO NumFiles
  54.   OPEN "FTEST" + LTRIM$(STR$(X)) FOR RANDOM AS #X
  55. NEXT
  56. CLOSE
  57. KILL "FTEST*."
  58.  
  59. FUNCTION DOSVer% STATIC
  60.   InRegs.AX = &H3000
  61.   CALL INTERRUPT(&H21, InRegs, OutRegs)
  62.   Major = OutRegs.AX AND &HFF
  63.   Minor = OutRegs.AX \ &H100
  64.   DOSVer% = Minor + 100 * Major
  65. END FUNCTION
  66.  
  67. SUB MoreFiles (NumFiles) STATIC
  68.   Dummy& = SETMEM(-1000)
  69.   InRegs.AX = &H6700
  70.   InRegs.BX = NumFiles + 5
  71.   CALL INTERRUPT(&H21, InRegs, OutRegs)
  72.   Dummy& = SETMEM(1000)
  73. END SUB
  74.  
  75.