home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / progm / disam.zip / DISAMTST.SBA < prev    next >
Text File  |  1990-06-02  |  4KB  |  131 lines

  1. `By Robert Pearce                                                 `87283
  2. `DISAMTST.SBA   DEMO PROGRAM TO TEST THE DISAM FILE HANDLER
  3. `   This is an S-BASIC source module
  4.  
  5. `***********************************************************************
  6. `**     Insure that the file handler is already loaded                **
  7. `***********************************************************************
  8.     DEF SEG=&H0012              'SET SEGMENT TO DFH3 EPA
  9.     X=PEEK(&H0)
  10.     DEF SEG                     'SET SEGMENT BACK TO BASIC
  11.     IF X<>234 THEN
  12.         PRINT "DISAM File Handler is not loaded"
  13.         STOP
  14.     END IF
  15.     PRINT "                  DISAM FILE TEST PROGRAM"
  16. `***********************************************************************
  17. `**     Solcit input for the DISAM file handler                       **
  18. `***********************************************************************
  19. |LOOP
  20.     INPUT "Enter function or 'end' ",A$
  21.     GOSUB MAKE.LOWER.UPPER
  22.     F$=LEFT$(A$,1)
  23.  
  24.     IF F$="E" THEN
  25.         SYSTEM                  'EXIT
  26.     END IF
  27.  
  28.     B1$=""
  29.     INPUT "Enter buffer number ",B1$
  30.     IF B1$<>"" THEN
  31.         B$=B1$                  'ASSUME A NEW BUFFER NUMBER
  32.     END IF
  33.  
  34.     IF F$="C" GOTO |SKIP
  35.  
  36.     IF F$="F" GOTO |SKIP
  37.  
  38.     IF F$="O" THEN
  39.         QFLAG=0
  40.         INPUT "Enter Filename ",R$
  41.         GOTO |SKIP
  42.     END IF
  43.  
  44.     IF F$="Q" THEN
  45.         QFLAG=1
  46.         INPUT "Enter Filename ",R$
  47.         GOTO |SKIP
  48.     END IF
  49.  
  50.     INPUT "Enter record ",R$
  51.  
  52. `***********************************************************************
  53. `**     Finish the function and set the required record lengths       **
  54. `***********************************************************************
  55. |SKIP
  56.     S=1                         'NEED 1 BYTE MINIMUM
  57.     IF F$="A" THEN
  58.         S=0
  59.     END IF
  60.     IF F$="P" THEN
  61.         S=0
  62.     END IF
  63.     IF F$="G" THEN
  64.         S=255-LEN(R$)           'SET UP RETURN RECORD LENGTH
  65.     END IF
  66.  
  67.     F$=F$+","+B$                'ADD BUFFER NUMBER TO FUNCTION
  68.  
  69.     R$=R$+SPACE$(S)             'PAD USER'S RECORD
  70.  
  71. `
  72. `***********************************************************************
  73. `**     Interact with the DISAM file handler                          **
  74. `***********************************************************************
  75.     DEF SEG=&H0012              'SET SEGMENT DFH3 EPA
  76.     DFH3=&H0                    'SET ENTRY POINT ADDRESS VALUE
  77.     CALL ABSOLUTE (F$,R$,DFH3)  'CALL SUBROUTINE (COMPILED VERSION)
  78.     DEF SEG                     'SET SEGMENT BACK TO BASIC
  79.  
  80. `***********************************************************************
  81. `**     Test and respond to the return codes                          **
  82. `***********************************************************************
  83.     IF LEN(R$)<>1 THEN
  84.         PRINT R$
  85.         GOTO |LOOP
  86.     END IF
  87.  
  88.     IF R$="0" THEN
  89.         PRINT "Function completed successfully"
  90.         GOTO |LOOP
  91.     END IF
  92.  
  93.     IF R$="1" THEN
  94.         PRINT "Record not found"
  95.         GOTO |LOOP
  96.     END IF
  97.  
  98.     IF R$="2" THEN
  99.         PRINT "Record already exists"
  100.         GOTO |LOOP
  101.     END IF
  102.  
  103.     IF R$="3" THEN
  104.         PRINT "End of File"
  105.         GOTO |LOOP
  106.     END IF
  107.  
  108.     IF R$="4" THEN
  109.         PRINT "Record length is either to long or to short"
  110.         GOTO |LOOP
  111.     END IF
  112.  
  113.     IF R$="5" THEN
  114.         PRINT "File sharing not allowed"
  115.         GOTO |LOOP
  116.     END IF
  117.  
  118.     IF R$="7" THEN
  119.         PRINT "DISAM file not found"
  120.         GOTO |LOOP
  121.     END IF
  122.  
  123.     IF R$="8" THEN
  124.         PRINT "The buffer requested is currently in use"
  125.         GOTO |LOOP
  126.     END IF
  127.  
  128.     PRINT "Invalid DISAM Request"
  129.     GOTO |LOOP
  130. END
  131.