1	REM MAGSAMD 4.2 - MAGSAM FILE DUMP UTILITY FOR CP/M & MICROSOFT BASIC
2	REM
3	REM PROPRIETARY SOFTWARE OF:
4	REM  MICRO APPLICATIONS GROUP
5	REM  7300 CALDUS AVENUE
6	REM  VAN NUYS, CA 91406
7	REM
8	REM (C) COPYRIGHT 1978, 1979 MAG 
9	REM
12	DIM MAGSAM%(4)
14	PRINT:PRINT:PRINT
16	PRINT "MAGSAMD 4.2 - MAGSAM FILE DUMP UTILITY"
18	PRINT "(C) COPYRIGHT 1978, 1979 MICRO APPLICATIONS GROUP "
20	PRINT: INPUT "ENTER INDEX FILE NAME: ",I$
22	MAGSAM%(1)=1: REM INDEX FILE NUMBER
24	PRINT: INPUT "ENTER DATA FILE NAME: ",D$
26	MAGSAM%(2)=2: REM DATA FILE NUMBER
28	PRINT: INPUT "ENTER OVERFLOW FILE NAME: ",O$
32	MAGSAM%(3)=3: REM OVERFLOW FILE NUMBER
90	PRINT: INPUT "ENTER DATA FILE RECORD LENGTH: ",D%
92	IF D%>255 THEN PRINT:PRINT">> RECORD LENGTH IS LIMITED TO 255 CHARACTERS.  PLEASE REENTER.":GOTO 90
100	OPEN "R",MAGSAM%(1),I$,256  
102	OPEN "R",MAGSAM%(2),D$,D% 
104	OPEN "R",MAGSAM%(3),O$,256
106	FIELD MAGSAM%(1),1 AS MAGSAM.H01$,2 AS MAGSAM.H02$,2 AS MAGSAM.H03$,
2 AS MAGSAM.H04$,2 AS MAGSAM.H05$,2 AS MAGSAM.H06$,
2 AS MAGSAM.H07$,2 AS MAGSAM.H08$,2 AS MAGSAM.H09$,
2 AS MAGSAM.H10$,2 AS MAGSAM.H11$
108	FIELÄ MAGSAM%(1),25µ AÓ MAGSAM.I01$
112	FIELD MAGSAM%(2),D% AS DATA.REC$
114	FIELD MAGSAM%(3),255 AS MAGSAM.O01$
116	GET # MAGSAM%(1),1
118	B$=MAGSAM.H01$
122	B0%=CVI(MAGSAM.H02$):B1%=CVI(MAGSAM.H03$):B2%=CVI(MAGSAM.H04$)
124	B3%=CVI(MAGSAM.H05$):B4%=CVI(MAGSAM.H06$):B5%=CVI(MAGSAM.H07$)
126	B6%=CVI(MAGSAM.H08$):B7%=CVI(MAGSAM.H09$):B8%=CVI(MAGSAM.H10$)
128	B9%=CVI(MAGSAM.H11$)
132	DUM%=0: REM BYPASS COMPILER ERROR IN 5.02
134	IF DUM%=0 THEN GOTO 200
200	PRINT:INPUT"PRINT INDEX FILE? (Y OR N): ",Y$
202	IF Y$="N" THEN GOTO 300
204	IF Y$<>"Y" THEN GOTO 200
206	PRINT:PRINT "HEADER RECORD 1"
208	PRINT"  INDEX RECL =";TAB(15);B0%
210	PRINT"  KEY LENGTH =";TAB(15);B2%
212	PRINT"  NEXT INDEX =";TAB(15);B3%
214	PRINT"  NEXT DATA  =";TAB(15);B4%
216	PRINT"  NEXT OVFLW =";TAB(15);B5%
218	PRINT"  DEL CHAIN  =";TAB(15);B6%
220	IF B3%<1 THEN PRINT:PRINT">> NO INDEX RECORDS PRESENT":GOTO 300
222	IB%=2:HEAD$="INDEX":RECNO%=2
224	WHILE RECNO%<=B3%
226	   GET # MAGSAM%(1),RECNO%
228	   B$=MAGSAM.I01$:B$=LEFT$(B$,INSTR(B$," ")-1)	
230	   GOSUB 1000: REM PRINT FORMATTED INDEX
232	   RECNO%=RECNO%+1
234	WEND
300	PRINT:INPUT"PRINT DATA FILE? (Y OR N): ",Y$
302	IF Y$="N" THEN GOTO 400
304	IF Y$<>"Y" THEN GOTO 300
306	IF B4%-1=0 THEN PRINT:PRINT">> NO DATA RECORDS PRESENT":GOTO 400
308	I%=1
310	WHILE I%<B4%
312	   GET # MAGSAM%(2),I%
314	   X$=DATA.REC$
316	   PRINT:PRINT"DATA RECORD ";I%
318	   PRINT X$
320	   I%=I%+1
322	WEND
400	PRINT:INPUT"PRINT OVERFLOW FILE? (Y OR N): ",Y$
402	IF Y$="N" THEN GOTO 500
404	IF Y$<>"Y" THEN GOTO 400
406	IF B5%-1=0 THEN PRINT:PRINT">> NO OVERFLOW RECORDS PRESENT":GOTO 500
408	IB%=1:HEAD$="OVERFLOW":RECNO%=1
410	WHILE RECNO%<B5%
412	   GET # MAGSAM%(3),RECNO%
414	   B$=MAGSAM.O01$:B$=LEFT$(B$,INSTR(B$," ")-1)
416	   IF LEFT$(B$,1)="O" THEN GOSUB 1000 ELSE GOSUB 2000
418	   RECNO%=RECNO%+1
420	WEND
500	CLOSE(1),(2),(3)
510	PRINT:INPUT"MORE PRINT? (Y OR N): ",P$
512	IF P$="N" THEN GOTO 600
514	IF P$="Y" THEN GOTO 20 
516	GOTO 510
600	PRINT:PRINT"MAGSAMD COMPLETE":PRINT
602	END
1000	REM  PRINT FORMATTED INDEX/OVRFLW
1002	PRINT:PRINT HEAD$;" RECORD";IB%
1004	PRINT " ID  KEY";TAB(B2%+8);"REC#"
1006	PRINT " --  ";
1008	FOR M%=1 TO B2%:PRINT"-";:NEXT M%
1010	PRINT "  ----"
1012	IB%=IB%+1
1014	PTR%=2
1016	WHILE PTR% < LEN(B$)
1018	   I$=MID$(B$,PTR%,1)
1020	   K$=MID$(B$,PTR%+1,B2%)
1022	   P$=MID$(B$,PTR%+B2%+1,4)
1024	   PRINT TAB(3);I$;"  ";K$;"  ";P$
1026	   PTR%=PTR%+B2%+5
1028	WEND
1030	RETURN
2000	REM  PRINT FORMATED DELETE REC
2002	PRINT:PRINT"DELETE CHAIN RECORD";IB%
2004	PRINT " ID  REC#"
2006	PRINT " --  ----"
2008	IB%=IB%+1
2010	PTR%=2
2012	WHILE PTR%<LEN(B$)
2014	   I$=MID$(B$,PTR%,1)
2016	   K$=MID$(B$,PTR%+1,4)
2018	   PRINT TAB(3);I$;"  ";K$
2020	   PTR%=PTR%+5
2022	WEND
2024	RETURN
