1 CLS:PRINT"A Mailform program for sorting appended Mailform files by 
 postcode or rewriting mailform files to postman data file using
 40 or 80 track single sided drives. Please follow the prompts."
6 PRINT"Written using the enhanced basic features of newdos 2.0 using
FF file formats and R open allowing put and get to the same file"
11 PRINT" To use this program FORMAT a disk using NEWDOS ":PRINT:PRINT"Append all files mailform files on the disk to be copied."
12 PRINT"Then follow the prompts ......The Householder will be inserted  if    space is blank and NSW put in State."
16 PRINT" You can alter this at will.....":CMD"PAUSE"
21 CLS:CLEAR 3000:DIMA$(10):DIMB$(10)
26 DEFFNSS$(D$)=LEFT$(D$+CHR$(95),INSTR(D$+CHR$(95),CHR$(95))-1) :'Clears all underline chars from string.
31 DEFFNPR$(A$,A%)=LEFT$(A$+STRING$(A%," "),A%):'Pad with blanks
34 DEFFNLN%(A$)=LEN(LEFT$(MID$(A$+",",INSTR(A$,","),LEFT$(A$+",",INSTR(A$+",",",")))))
100 SG$=STRING$(63,131)
110 CLS:PRINTSG$;
120 PRINT:PRINT:PRINT"
<1> Convert and sort Mailform records
<2> Change Mailform records


";SG$
130 PRINT@896,"Press the number of your Selection,
           or press <up-arrow> to end...";
140 GOSUB20000:A%=INSTR(CHR$(91)+"12",AS$):IFA%=0THEN140ELSEONA%GOTO150,160,1130
150 CLOSE:END
160 'go to routines
170 GOSUB 200
180 GOSUB215:GOSUB625:GOTO800
200 CLS:INPUT" Name of File To process ??";FA$
205 INPUT" No of records in file to start at 1-2800";AN%
210 RETURN
215 INPUT"NAME OF FILE TO BE STORED ??";FB$
220 INPUT" No of Records already in file?? ";AM%
225 RETURN
615 OPEN"I",1,FA$,"FF",128
620 RETURN
625 OPEN"E",2,FB$,"FF",128 'NAME OF NEW DATA FILE
627 RETURN
630 OPEN"R",3,"POSTDATA/MLD","FF",128 :'NAME OF NEW DATA FILE
635 RETURN
800 Z=2000:G=1:AO=960:'POSTCODE START AND RECORD NO TO START
810 GOSUB615
840 'ONERROR GOTO340
845 PRINT@265,"PASS No..";G:G=G+1:Z=Z+50
850 GET1,AN%,15010
860 PRINT@512,A$:PRINTA2$:PRINTA3$:PRINTA4$:PRINTA5$:PRINTA6$
870 GOSUB950
880 GOTO850
950 S=ASC(LEFT$(A2$,1)):IFS<40 OR S>90 THEN A2$="THE HOUSEHOLDER "
960 T=VAL(RIGHT$(A4$,4)):IFT=ZORT<ZANDT>Z-100GOSUB1040:PUT2,,15010:GOTO980
970 S=VAL(RIGHT$(A4$,5)):IFS=ZORS<ZANDS>Z-100GOSUB1050:PUT2,,15010
980 PRINT@340,"FILE NO..";AN%;"PCode";S;T:AN%=AN%+1:GOSUB1060
990 PRINT@411,"Compare with "Z
1000 PRINT@462,"PROCESSING FILE NO. "AN%"PUTTING FILE "AM%
1010 IFEOF(1)THENAN%=1:GOTO840
1020 IFZ>2100 THEN 1070
1030 RETURN
1040 A4$=LEFT$(A4$,17)+CHR$(95)+"NSW"+RIGHT$(STR$(T),4):AM%=AM%+1:RETURN
1050 A4$=LEFT$(A4$,17)+CHR$(95)+"NSW"+RIGHT$(STR$(S),4):AM%=AM%+1:RETURN
1060 IF AN%>2800OR AM%>2800THENCLOSE:GOTO100
1070 IF Z>2100THEN CLOSE:GOTO100
1080 RETURN
1090 PRINT@896,"Sector error at "AN%
1100 AN%=AN%+1:RESUME850
1130 CLS:PRINT"This section takes mailform files and transfers them to
postdata/mld files. On using postman the first operation is to 
sort the files....
Have a blank prepared postman disk ready for adding the mailform"
1140 PRINT"Files
Also have you Appended mailform Disk inserted and ready to go
Again The householder will be insertted in any blank company
space and Company name area will be transferred to name...":CMD"PAUSE"
1150 GOSUB200:GOSUB615:GOSUB630
1160 GET3,1,15020
1170 AQ%=CVI(MID$(B$,9,2))
1180 AR%=CVI(MID$(B$,5,2))
1190 PRINT"Records start at sector..."AQ%;"Maximum no..";AR%:AQ%=2*AQ%
1200 GET1,AN%,15010
1210 IF EOF(1)THEN GOSUB1440:CLOSE:GOTO100
1220 IF AQ%>AR%THEN GOSUB1440:CLOSE:GOTO100
1230 FOR A=1TO10:B$(A)=" ":NEXT
1240 C1$=FNSS$(A5$):S$=LEFT$(C1$,3):IFS$="NSW"THENC$="   "ELSEC1$=" ":'Code number set to blanks
1250 B1$=FNPR$(C1$,10):PRINT@512,"Code no... ";B1$
1260 C2$=FNSS$(A$)
1270 D$=LEFT$(C2$,2):IFD$="P "THENC2$=""ELSEC2$=FNSS$(A$)
1280 'F%=FNLN%(C2$):PRINTF%:C2$=LEFT$(C2$,F%)
1290 B2$=FNPR$(C2$,15):PRINT@576,"Last Name..."B2$;
1300 B3$=FNPR$(B3$,15):PRINT"First Name..."B3$:'SET FIRST NAME TO BLANKS
1310 C4$=FNSS$(A2$):D$=LEFT$(C4$,3):IFD$="THE"THENB4$="The Householder"ELSEIFD$="   "THENB4$="The Householder":GOTO1340
1320 S=ASC(LEFT$(A2$,1)):IFS>40 OR S<90 THEN B2$=C4$:PRINT@576,"Last Name..."B2$;
1330 B4$="The Householder"
1340 PRINT@640,"Company Name..."B4$
1350 C5$=FNSS$(A3$):B5$=FNPR$(C5$,26):PRINT"Adress.."B5$;
1360 C6$=LEFT$(A4$,15):C6$=FNSS$(C6$):B6$=FNPR$(C6$,15):PRINTB6$;
1370 B7$="NSW":B7$=FNPR$(B7$,9):PRINTB7$;
1380 PS$=RIGHT$(A4$,5):PS%=VAL(LEFT$(PS$,1)):IFPS%=2THENC8$=FNSS$(PS$):B8$=FNPR$(C8$,9):PRINTB8$;:GOTO1400
1390 T%=VAL(RIGHT$(A4$,4)):C8$=STR$(T%):B8$=FNPR$(C8$,9):PRINTB8$;
1400 B9$=FNPR$(B9$,2)
1410 B10$=FNPR$(B10$,5)
1420 PUT3,AQ%,15000
1430 AN%=AN%+1:AQ%=AQ%+1:PRINT"Putting Record No..."AT%:AT%=AT%+1:GOTO1200
1440 GET3,1,15020
1450 PRINT"Records transferred....";AN%
1460 B$=LEFT$(B$,6)+MKI$(AN%)+RIGHT$(B$,120)
1470 PUT3,1,15020
1480 RETURN
1490 B2$=FNPR$(B2$,15):PRINT@576,"Last Name...";B2$:'SET LAST NAME
1500 RETURN
15000 (10)B1$,(15)B2$,(15)B3$,(26)B4$,(26)B5$,(15)B6$,(5)B7$,(9)B8$,(2)B9$,(5)B10$;
15010 (25)A$,(25)A2$,(25)A3$,(25)A4$,(14)A5$,(14)A6$;

15020 (128)B$;
20000 AS$=INKEY$:IFAS$=""THEN20000ELSERETURN
