REM MAGSAMD 3.0 - MAGSAM/E FILE DUMP UTILITY FOR CP/M AND CB80
REM
REM CB80 VERSION - REAL RECORD NUMBERS
REM
REM PROPRIETARY SOFTWARE OF:
REM  MICRO APPLICATIONS GROUP
REM  7300 CALDUS AVENUE
REM  VAN NUYS, CA 91406
REM
REM (C) COPYRIGHT 1978-1982 MAG 
REM
      REC.LEN%=256
      DIM MAGSAM(4)
      PRINT:PRINT:PRINT
      PRINT "MAGSAMD 3.0 - MAGSAM/E FILE DUMP UTILITY"
      PRINT "(C) COPYRIGHT 1978-1982 MICRO APPLICATIONS GROUP "
10    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
100   OPEN I$ RECL REC.LEN% AS MAGSAM(1), \  
           D$ RECL D AS MAGSAM(2), \ 
           O$ RECL REC.LEN% AS MAGSAM(3)
      READ # MAGSAM(1);B$,B0,B1,B2,B3,B4,B5,B6,B7,B8,B9
200   PRINT:INPUT"PRINT INDEX FILE? (Y OR N): ";Y$
      IF Y$="N" THEN GOTO 300 
      IF Y$<>"Y" THEN GOTO 200
      PRINT:PRINT "HEADER RECORD 1"
      PRINT"  INDEX RECL =";TAB(15);B0
      PRINT"  KEY LENGTH =";TAB(15);B2
      PRINT"  NEXT INDEX =";TAB(15);B3
      PRINT"  NEXT DATA  =";TAB(15);B4
      PRINT"  NEXT OVFLW =";TAB(15);B5
      PRINT"  DEL CHAIN  =";TAB(15);B6
      IF SIZE(I$)<1 THEN PRINT:PRINT">> NO INDEX RECORDS PRESENT":GOTO 300
      IF END # MAGSAM(1) THEN 300
      IB%=2:HEAD$="INDEX"
210   READ # MAGSAM(1);B$
      GOSUB 1000: REM PRINT FORMATTED INDEX
      GOTO 210
300   PRINT:INPUT"PRINT DATA FILE? (Y OR N): ";Y$
      IF Y$="N" THEN GOTO 400
      IF Y$<>"Y" THEN GOTO 300
      IF SIZE(D$)=0 THEN PRINT:PRINT">> NO DATA RECORDS PRESENT":GOTO 400
      I=1
      IF END # MAGSAM(2) THEN 400
310   READ # MAGSAM(2),I; LINE X$
      PRINT:PRINT"DATA RECORD ";I
      PRINT TAB(3);X$
      I=I+1:GOTO 310
400   PRINT:INPUT"PRINT OVERFLOW FILE? (Y OR N): ";Y$
      IF Y$="N" THEN GOTO 500
      IF Y$<>"Y" THEN GOTO 400
      IF SIZE(O$)=0 THEN PRINT:PRINT">> NO OVERFLOW RECORDS PRESENT":GOTO 500
      IF END # MAGSAM(3) THEN 500
      IB%=1:HEAD$="OVERFLOW"
410   READ # MAGSAM(3); B$
      IF LEFT$(B$,1)="O" THEN GOSUB 1000 \
      ELSE GOSUB 2000
      GOTO 410
500   CLOSE(1),(2),(3)
510   PRINT:INPUT"MORE PRINT? (Y OR N): ";P$
      IF P$="N" THEN GOTO 600
      IF P$="Y" THEN GOTO 10 
      GOTO 510
600   PRINT:PRINT"MAGSAMD COMPLETE":PRINT
      STOP
1000  REM  PRINT FORMATTED INDEX/OVRFLW
      PRINT:PRINT HEAD$;" RECORD";IB%
      PRINT " ID  KEY";TAB(B2+8);"REC NO"	
      PRINT " --  ";
      FOR M%=1 TO B2:PRINT"-";:NEXT M%
      PRINT "  ------"	
      IB%=IB%+1
      PTR%=2
      WHILE PTR% < LEN(B$)
         I$=MID$(B$,PTR%,1)
         K$=MID$(B$,PTR%+1,B2)
         P$=MID$(B$,PTR%+B2+1,6)
         PRINT TAB(3);I$;"  ";K$;"  ";P$
         PTR%=PTR%+B2+7	
      WEND
      RETURN
2000  REM  PRINT FORMATED DELETE REC
      PRINT:PRINT"DELETE CHAIN RECORD";IB%
      PRINT " ID  REC NO"	
      PRINT " --  ------"
      IB%=IB%+1
      PTR%=2
      WHILE PTR%<LEN(B$)
         I$=MID$(B$,PTR%,1)
         K$=MID$(B$,PTR%+1,6)	
         PRINT TAB(3);I$;"  ";K$
         PTR%=PTR%+7	
      WEND
      RETURN
