Mail merge documents with a database.
Appears on
Library tape of the Indiana Sinclair Timex User’s Group.
Source Code
10 LET q=23670: LET r=23671: RESTORE : FOR j=60000 TO 60013: READ k: POKE j,k: NEXT j: GO TO 110 20 DATA 1,0,0,33,0,0,84,93,33,0,0,237,176,201 30 PRINT b$( TO y-x): LET x=y+1 40 IF x1=22 AND p=1 THEN COPY : CLS : LET x1=0 50 IF x1=22 AND p=0 THEN INPUT c$: CLS : LET x1=0 60 LET x1=x1+1: LET x4=x4+1: RETURN 70 RANDOMIZE v1: POKE 60001,PEEK q: POKE 60002,PEEK r: RANDOMIZE v2: POKE 60004,PEEK q: POKE 60005,PEEK r: RANDOMIZE v3: POKE 60009,PEEK q: POKE 60010,PEEK r: RANDOMIZE USR 60000: RETURN 80 IF LEN z$>10 THEN LET b$=" " 90 IF LEN z$<>10 THEN LET z$=z$+" ": GO TO 90 100 INPUT "Key C if OK ";b$: RETURN 110 CLS : PRINT TAB 10;"MERGE 1" 120 PRINT ''"Type the letter name ": INPUT z$: PRINT ''z$: GO SUB 80: IF b$<>"c" OR z$="" THEN GO TO 10 130 PRINT ''"Start the tape": LOAD z$CODE : CLS 140 LET c1=PEEK 37998+256*PEEK 37999: POKE 37999+c1,143: IF c1>4500 THEN PRINT "Letter too long": PAUSE 250: GO TO 10 150 LET p=(1 AND IN 251=58)+(0 AND IN 251=126) 160 LET x3=80: IF p=1 THEN PRINT "Printer ON. How many lines/page?": INPUT x3 170 LET v1=c1: LET v2=61000: LET v3=38000: GO SUB 70 180 PRINT "Type the file name ": INPUT z$: PRINT ''z$: GO SUB 80: IF b$<>"c" OR z$="" THEN GO TO 170 190 PRINT ''"Start the tape": LOAD z$CODE : CLS 200 LET c5=PEEK 37998+256*PEEK 37999: LET a=PEEK 37997 210 LET z=38000 220 CLS : PRINT FLASH 1;"Building the next letter": DIM b(a+1): IF PEEK z=143 THEN GO TO 650 230 LET b(1)=z: FOR j=1 TO a 240 IF PEEK z=131 THEN LET b(j+1)=z+1: GO TO 260 250 LET z=z+1: GO TO 240 260 LET z=z+1: NEXT j 270 PRINT "Fields found" 280 LET w=61000: LET x=32500 290 IF PEEK w=94 THEN GO TO 320 300 POKE x,PEEK w: LET x=x+1: LET w=w+1: IF w=61000+c1 THEN CLS : GO SUB 380: LET w=61000: LET z=z+1: GO TO 220 310 GO TO 290 320 LET w=w+1: LET b$="" 330 IF PEEK w=94 OR PEEK w=44 THEN GO TO 350 340 LET b$=b$+CHR$ PEEK w: LET w=w+1: GO TO 330 350 LET f=VAL b$: FOR j=b(f) TO b(f+1)-2: POKE x,PEEK j: LET x=x+1: NEXT j 360 IF PEEK w=94 THEN LET w=w+1: LET x=x-1: GO TO 290 370 GO TO 320 380 LET x=32500 390 LET x1=1: LET x2=x1: LET x4=x1 400 LET y=31 410 LET f=PEEK x: IF f=144 THEN GO TO 440 420 IF f=42 THEN GO TO 650 430 IF f>127 THEN LET x=x+1: IF f<>131 THEN GO TO 520 440 IF INKEY$="z" THEN GO TO 10 450 LET f=0: LET b$="": FOR j=x TO x+y: LET b$=b$+CHR$ PEEK j: IF (PEEK j>127 AND PEEK j<>144) AND f=0 THEN LET f=j 460 NEXT j: LET y=j: IF f>0 THEN LET y=f 470 LET f=0: FOR j=x TO y: IF PEEK j=32 THEN LET f=1: LET j=y 480 NEXT j: IF f=0 THEN GO TO 500 490 IF PEEK y<>32 AND PEEK y<128 THEN LET y=y-1: GO TO 490 500 GO SUB 30: IF PEEK y>127 THEN LET x=x-1: 510 GO SUB 590: GO TO 400 520 IF f<>139 THEN GO TO 560 530 LET k=x3-x4: IF k<3 THEN FOR j=1 TO k: PRINT : GO SUB 40: GO SUB 590: NEXT j: GO TO 550 550 PRINT TAB 5;: LET y=26: GO TO 410 560 IF f<>134 THEN GO TO 620 570 LET k=x3-x4: PRINT : GO SUB 40: FOR j=1 TO k: PRINT : GO SUB 40: NEXT j: GO SUB 600 580 GO TO 400 590 IF x4<x3 OR p=0 THEN RETURN 600 FOR j=1 TO 5: PRINT : GO SUB 40: IF j=3 THEN PRINT TAB 15;x2: LET x2=x2+1: GO SUB 40 610 NEXT j: LET x4=1: RETURN 620 IF p=0 THEN FOR j=1 TO 5: PRINT : NEXT j 630 IF p=1 THEN COPY 640 LET z=z+1: GO TO 220 650 CLS : PRINT AT 9,9;"End of list"'''"Key C for another copy": INPUT b$: IF b$="c" THEN GO TO 200 660 SAVE "MERGE 1" LINE 1: VERIFY ""