REM MAGSAMX 3.0 - MAGSAM/E TUTORIAL PROGRAM FOR CP/M AND CB80
REM
REM CB80 VERSION - REAL RECORD NUMBERS
REM
REM PROPRIETARY SOFTWARE OF:
REM
REM  MICRO APPLICATIONS GROUP
REM  7300 CALDUS AVENUE
REM  VAN NUYS, CA 91406
REM
REM (C) COPYRIGHT 1978-1982 MAG
REM 
      DIM MAGSAM$(20),MAGSAM(20)
      PRINT:PRINT:PRINT
      PRINT "MAGSAMX 3.0 - MAGSAM/E TUTORIAL PROGRAM"
      PRINT "(C) COPYRIGHT 1978-1982 MICRO APPLICATIONS GROUP"
      PRINT: INPUT "ENTER INDEX FILE NAME: ";I$
      MAGSAM(1)=1: REM INDEX FILE NUMBER
      PRINT: INPUT "ENTER DATA FILE NAME: ";D$
      MAGSAM(2)=2: REM DATA FILE NUMBER
      PRINT: INPUT "ENTER OVERFLOW FILE NAME: ";O$
      MAGSAM(3)=3: REM OVERFLOW FILE NUMBER
      PRINT: INPUT "ENTER DATA FILE RECORD LENGTH: ";D%
      PRINT: INPUT "ENTER KEY LENGTH: "; MAGSAM(4)
100   PRINT:INPUT"WILL DUPLICATE KEYS BE ALLOWED (Y OR N)? ";DK$
      DK$=UCASE$(DK$)
      IF DK$<>"Y" AND DK$<>"N" THEN GOTO 100	
      IF DK$="Y" THEN MAGSAM$(3)="D"
200   PRINT:INPUT"IS INDEX BUFFERING TO BE UTILIZED (Y OR N)? ";IB$
      IB$=UCASE$(IB$)	
      IF IB$<>"Y" AND IB$<>"N" THEN GOTO 200	
      IF IB$="Y" THEN MAGSAM$(6)="B"
      IF END # 1 THEN 202
      OPEN I$ RECL 256 AS 1
      GOTO 203
202   CREATE I$ RECL 256 AS 1
203   IF END # 2 THEN 204
      OPEN D$ RECL D% AS 2
      GOTO 205
204   CREATE D$ RECL D% AS 2
205   IF END # 3 THEN 206
      OPEN O$ RECL 256 AS 3
      GOTO 210
206   CREATE O$ RECL 256 AS 3
210   PRINT: INPUT "ENTER FUNCTION CODE OR 'END': ";MAGSAM$(1)
      MAGSAM$(1)=UCASE$(MAGSAM$(1))
      IF MAGSAM$(1)="END" THEN GOTO 930
      IF MAGSAM$(1)="RO" THEN \
         PRINT:PRINT"FILE REORGANIZATION IS NOT SUPPORTED BY MAGSAMX.": \
         PRINT"SEE THE FILE REORGANIZATION UTILITY PROGRAM, MAGSAMRX.": \
         GOTO 210
      IF RIGHT$(MAGSAM$(1),1)="N" OR \
         MAGSAM$(1)="OO" \
            THEN GOTO 300
      PRINT: INPUT "ENTER KEY VALUE: ";MAGSAM$(2)
      IF MAGSAM$(1)<>"WA" AND MAGSAM$(1)<>"WL" AND MAGSAM$(1)<>"WI" \
         THEN GOTO 250
      PRINT: INPUT "ENTER DATA RECORD TEXT: ";LINE R$
      GOTO 300
250   IF MAGSAM$(1)="SA" OR MAGSAM$(1)="SL" OR MAGSAM$(1)="SI" OR \
         (DK$="Y" AND \
         (MAGSAM$(1)="DR" OR MAGSAM$(1)="KD" OR MAGSAM$(1)="SD")) THEN \
            PRINT: INPUT "ENTER DATA RECORD NUMBER: ";MAGSAM(5)
300   GOSUB 60000: REM MAGSAM 
      IF MAGSAM(8)=0 THEN GOTO 400
      PRINT: PRINT ">> ERROR: ";MAGSAM(8): GOTO 910
400   IF MAGSAM$(1)="OO" THEN GOTO 910
      IF LEFT$(MAGSAM$(1),1)="R" THEN GOTO 500
      IF LEFT$(MAGSAM$(1),1)="W" AND MAGSAM$(18)<>"S" THEN \
         GOTO 600 \
      ELSE \
         GOTO 900
500   PRINT:PRINT"DATA RECORD NUMBER = ";MAGSAM(9)
      READ # MAGSAM(2),MAGSAM(9); LINE X$
      PRINT "KEY = ";MAGSAM$(2)
      PRINT X$
      GOTO 900
600   PRINT:PRINT "DATA RECORD NUMBER = ";MAGSAM(9)
      PRINT # MAGSAM(2),MAGSAM(9);R$
900   IF MAGSAM(7)<>0 THEN \
         PRINT:PRINT "NUMBER OF OVERFLOW ACCESSES = ";MAGSAM(7)
910   X$=""
      GOTO 210
930   PRINT:PRINT"MAGSAMX COMPLETE":PRINT
      CLOSE MAGSAM(1),MAGSAM(2),MAGSAM(3)
      STOP
%INCLUDE MAGSAM.CB8
      END
