REM MAGSAMD 3.0 - MAGSAM FILE DUMP UTILITY
REM  MICRO APPLICATIONS GROUP
REM  7300 CALDUS AVE
REM  VAN NUYS, CA  91406
REM  (C) COPYRIGHT 1978, 1979 MAG 
REM
      REC.LEN%=256
      DIM MAGSAM%(4)
      PRINT:PRINT:PRINT
      PRINT "MAGSAMDX 3.0 - MAGSAM FILE DUMP UTILITY"
      PRINT "(C) COPYRIGHT 1978, 1979 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)
200   PRINT:INPUT"PRINT INDEX FILE? (Y OR N): ";Y$
      IF Y$="N" THEN GOTO 300 
      IF Y$<>"Y" THEN GOTO 200
      PRINT
      IF SIZE(I$)=0 THEN PRINT">> NO INDEX RECORDS PRESENT"
      READ # MAGSAM%(1);B$,B0,B1,B2,B3,B4,B5,B6,B7,B8,B9
      PRINT B$;" ,";B0;",";B1;",";B2;",";B3;",";B4;",";B5;",";B6;",";B7;",";B8;",";B9
      IF END # MAGSAM%(1) THEN 300
      IB%=1: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
      PRINT
      IF SIZE(D$)=0 THEN PRINT">> NO DATA RECORDS PRESENT"
      I=1
      IF END # MAGSAM%(2) THEN 400
310   READ # MAGSAM%(2),I; LINE X$
      PRINT 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"
      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%
      IB%=IB%+1
      PTR%=2
      WHILE PTR% < LEN(B$)
         K$=MID$(B$,PTR%,B2+1)
         P$=MID$(B$,PTR%+B2+1,4)
         PRINT K$,P$
         PTR%=PTR%+B2+5
      WEND
      RETURN
2000  REM  PRINT FORMATED DELETE REC
      PRINT:PRINT"DELETE CHAIN RECORD";IB%
      IB%=IB%+1
      PTR%=2
      WHILE PTR%<LEN(B$)
         K$=MID$(B$,PTR%,5)
         PRINT K$
         PTR%=PTR%+5
      WEND
      RETURN
