1 SUB M11SET & 2 !******************************************************************** & ! & ! & ! M11SET & ! & ! Sets up the system for printing & ! & ! & !******************************************************************** & ! 3 ! Program : M11SET & ! Version : 00 26-FEB-82 & ! Programmer : Jean Fullerton & ! Releaser : & ! & !--------------------------------------------------------------------- 11 ! & ! & ! C O P Y R I G H T & ! & ! & !--------------------------------------------------------------------- 20 ! ! Modification History ! ! 21-Mar-84 Changed default output device from "1" to "D" ! in line 14120. (Subroutine 14000 is stored as ! a separate source, SUBPRT) ! ! 21-Mar-84 Allow user to specify form length for listings. ! Added MAP LSTMAX at line 690 and line 4150. ! ! 4-May-84 Modified this and related modules to use RFA access ! to mailing list files. This improves performance ! compared to access by primary ID. MAPRFA, ! lines 3330 - 3350 ! ! 24-Sep-84 Changed lines 3000 - 3300 to allow multiple key sorts. ! !--------------------------------------------------------------------- 100 ! & ! & ! & ! Description: & ! & ! This routine is used to set up the printing of addresses on labels & ! or on a listing. SMAIL then calls either M11PRT or M11LB1/M11LB2. & ! & ! future enhancements: allow multiple answers to the sort question & ! (for example, "S,A" means sort by State, & ! then do a subsort by Alternate ID). & ! & !--------------------------------------------------------------------- 200 ! & ! & ! Interfaces: & ! & ! & !--------------------------------------------------------------------- 300 ! & ! & ! Input / Output: & ! & ! & ! Channel Filename Map name Status at entry/exit & ! ------- --------- -------- -------------------- & ! & ! CH.SORT% closed / closed & ! & !--------------------------------------------------------------------- 400 ! & ! & ! Variable and Array Definitions: & ! & ! & ! ERL Line in which error occurred & ! & ! ERR Set to error number after error & ! & !--------------------------------------------------------------------- 600 !-------------------------------------------------------------------- & ! & ! & ! COMMON Statements & ! & ! & !--------------------------------------------------------------------- 650 !-------------------------------------------------------------------- & ! & ! & ! MAP Statements & ! & ! & !--------------------------------------------------------------------- 690 MAP (LSTMAX) MAX.PRT.LINES% ! This map is used to store the form length for short or full ! listings. It is used in M11SET and M11PRT. 700 ! & ! & ! Subprograms: & ! & ! & ! & !-------------------------------------------------------------------- & ! 800 ! Subroutines: & ! & !-------------------------------------------------------------------- & ! & ! Functions: & ! & !-------------------------------------------------------------------- & 1000 !******************************************************************** & ! & ! & ! S T A R T P R O G R A M L O G I C & ! & ! & !******************************************************************** & 1010 ON ERROR GOTO 19000 & \ ERR.CALLNAM$ = ERR.PROGNAM$ & \ ERR.PROGNAM$ = "M11SET VER:00" & \ ERR.SUBNAM$ = "" & \ ERR.MSG$ = "Unexpected fatal error" & \ PLEASE.WAIT$ = "The next address is in use by another user. Please wait." & ! Set standard error trap. Set up common for error reporting. & & 1040 AND% = 1% & \ OR% = 2% & & \ ALL.SP% = 2% & & ! Initialize constants. & 2000 !-------------------------------------------------------------------- & ! & ! Entire List or just sublist ? & ! & !-------------------------------------------------------------------- & 2100 CALL M11SCD (SCR.LIST.SELECT%) & ! Show the list selection choice. & 2120 CALL M11SCR (ANS$, 18%, 42%, 1%, "A", "A", F.END%) & \ GO TO 9000 IF F.END% & ! Get the answer, clear out if 'END'. & 2140 M11.LIST.CODE$ = ANS$ & \ GO TO 2200 IF POS ("AST", ANS$, 1%) > 0% & ! Save answer. & 2190 CALL M11SCD (SCR.HLP.13%) & \ M11.MSG$ = " " & \ GO SUB 14900 & \ GO TO 2100 & ! Give help because answer not acceptable (including help requests) & 2200 GO TO 2300 UNLESS M11.LIST.CODE$ = "S" & \ DEFAULT$ = "" & \ DEFAULT$ = M11.SUBLIST.NAME$ IF M11.SUBLIST.CODE% = PERM% & \ CALL M11SCR (NAM$, 10%, 41%, 10%, DEFAULT$, "A", F.END%) & \ CALL M11SCW (ERASE.EOL$, 10%, 41%) IF F.END% & \ GO TO 2120 IF F.END% & \ GO TO 2190 IF NAM$ = "?" & \ IF NAM$ = "" & THEN IF M11.SUBLIST.CODE% = TEMP% & THEN GO SUB 12100 ! convert sublist & \ GO TO 3000 & ELSE M11.MSG$ = "A temporary sublist does not currently exist." & \ GO TO 2290 & ELSE IF M11.SUBLIST.CODE% = PERM% AND NAM$ = M11.SUBLIST.NAME$ & THEN GO SUB 12100 ! convert sublist & \ GO TO 3000 & ELSE SAV.PRIME.ID$ = SUB.CHR$+ SEG$(NAM$ + SPACE$(10%),1%,10%) & \ SUB.KEY0$ = SAV.PRIME.ID$ + "00001" & 2210 GET #CH.ADD%, KEY #0% EQ SUB.KEY0$ & 2220 M11.SUBLIST.CODE% = PERM% & \ M11.SUBLIST.NAME$ = NAM$ & \ GO SUB 12000 ! Load sublist def. & \ GO SUB 12100 ! Convert sublist def & \ GO TO 3000 & ! If the answer is "sublist"... & ! Ask the user which one (the default is the current one, if any). & ! Unless the user picks the current one, send her back to M11SUB. & 2289 M11.MSG$ = "Sublist " + NAM$ + " does not currently exist." & ! Program traps back to here if the stored sublist does not exist. & 2290 CALL M11SCW (M11.MSG$, 23%, 1%) & \ M11.MSG$ = "Do you wish to go back to create that sublist definition (Y/N)?" & \ CALL M11SCW (M11.MSG$, 24%, 1%) & \ CALL M11SCR (ANS$, 24%, 66%, 1%, "Y", "Y", F.END%) & \ CALL M11SCW (ERASE.EOL$, 23%, 1%) & \ GO TO 2100 IF F.END% & \ IF ANS$ = "Y" THEN ERR.CODE% = 10% & \ GO TO 9000 & ELSE GO TO 2100 & ! Handle the case where the user has requested a sublist that does & ! not exist (yet). & 2300 GO TO 3000 UNLESS M11.LIST.CODE$ = "T" & \ IF M11.SUBLIST.CODE% = TEMP% & THEN GO SUB 12100 & \ GO TO 3000 & ELSE M11.MSG$ = "A temporary sublist does not currently exist." & \ GO TO 2290 & ! If the temporary sublist was requested, check that it exists. & 3000 !-------------------------------------------------------------------- & ! & ! Sort Options & ! & !-------------------------------------------------------------------- & 3100 CALL M11SCD (SCR.PRT.SORT.MENU%) & \ CALL M11SCW (HDR.CAT.PROMPT$(J%), 7%+J%, 52%) FOR J% = 1% TO 6% & ! Show the sort option menu (and the category labels). & 3120 CALL M11SCR (ANS$, 22%, 40%, 9%, "P", "A", F.END%) & \ GO TO 2000 IF F.END% & \ ANS$ = "P" IF ANS$ = " " & \ GO TO 3190 IF ANS$ = "?" & ! Get the answer, clear out if 'END'. & 3130 OPTIONS_LIST$ = "/P/A/C/N/L1/L2/L3/T/S/Z/1/2/3/4/5/6/PRE/" ANS$ = EDIT$(ANS$,2%) M11.SORT.CODE$(I%) = "" FOR I% = 1% TO 3% M11.SORT.OPTIONS% = 0% FOR OPT% = 1% TO 3% COMMA% = POS(ANS$,",",1%) IF COMMA% = 0% THEN KEY$ = ANS$ ELSE KEY$ = SEG$(ANS$,1%, COMMA%-1%) ANS$ = SEG$(ANS$,COMMA%+1%,LEN(ANS$)) END IF IF POS(OPTIONS_LIST$, ("/" + KEY$ + "/"), 1%) = 0% THEN GOTO 3180 ELSE M11.SORT.CODE$(OPT%) = KEY$ END IF GOTO 3170 IF KEY$ = "PRE" AND OPT% <> 1% GOTO 3160 IF KEY$ = "Z" AND M11.SORT.CODE$(1%) = "PRE" GOTO 3150 IF ( KEY$ = "P" OR KEY$ = "A" ) AND OPT% > 1% GOTO 3150 IF OPT% > 1% AND (M11.SORT.CODE$(1%) = "P" & OR M11.SORT.CODE$(1%) = "A") GOTO 3140 IF COMMA% = 0% NEXT OPT% ! Define the options list and initialize the sort options. ! Accept a comma separated list of up to three sort options. ! Extract and validate each sort option in the input string. ! Restrictions are: ! - PRE must be first option if selected. ! - don't accept 'Z' with 'PRE' ! - multiple options not allowed with 'P' or 'A' 3140 M11.SORT.OPTIONS% = OPT% M11.SORT.CODE$ = M11.SORT.CODE$(1%) GOTO 3200 ! Save the number of sort options. V 1.0 did not allow multiple ! sort options and used M11.SORT.CODE$ to store the only sort option. ! the item is defined here since it is referenced in a number of ! modules. 3150 M11.MSG$ = "Multiple sort options are not allowed with 'P' or 'A'" GOSUB 14900 GO TO 3120 ! Don't allow multiple options if sort by primary or alternate key 3160 M11.MSG$ = "You cannot choose both 'PRE' and 'Z'" GOSUB 14900 GO TO 3120 ! For presorts, Zip Code is the major key. Don't allow user ! to specify 'Z' and 'PRE'. 3170 M11.MSG$ = "PRE must be the first sort option." GOSUB 14900 GO TO 3120 ! If presorting is selectied, PRE must be the first sort option ! since Zip Code will be the major key of the sort. 3180 M11.MSG$ = "Please choose from available options or type ? or END" GOSUB 14900 GO TO 3120 ! Check for a proper answer, ! and set the index into the address field length array. ! Warn about bad choice and return for new reply. 3190 CALL M11SCD (SCR.HLP.16%) & \ M11.MSG$ = " " & \ GO SUB 14900 & \ GO TO 3100 & ! Give help because answer not acceptable (including help requests). & 3200 IF SEG$ (M11.SORT.CODE$(1%), 1%, 2%) = "PR" THEN M11.PRESORT% = TRUE% & ELSE M11.PRESORT% = FALSE% & ! Save the answer. & 3220 IF M11.PRESORT% AND HDR.COUNTRY$ <> "A" THEN & M11.MSG$ = "Warning: PRESORT only applies to US addresses." & \ GO SUB 14900 & \ GO TO 3120 IF F.END% & ! Check that the addresses to be PRESORTed are from a US mail list. & 3300 !-------------------------------------------------------------------- & ! & ! Any acceptable addresses ? & ! & !-------------------------------------------------------------------- & 3320 CLOSE #CH.KB% & \ C = CTRLC & \ OPEN "KB:" AS FILE #CH.KB% & \ IF M11.SORT.CODE$ = "A" & THEN RESTORE #CH.ADD%, KEY #1% & ELSE RESTORE #CH.ADD%, KEY #0% & ! First, define the key for access. & 3330 IF M11.SORT.CODE$ = "A" & THEN GET #CH.ADD%, KEY #1% GE " " & ELSE GET #CH.ADD%, KEY #0% GT SUB.CHR$ + "zzzzzzzzzzzzzzz" & \ FIRST_RECORD_RFA = GETRFA (CH.ADD% ) & ! Get the first name record (after any header records). & ! Get the record's RFA if the sort code is not "A". & 3340 MOVE FROM #CH.ADD%, REC$ = RECOUNT & \ CALL M11UPK (REC$) & \ GO TO 4000 IF M11.LIST.CODE$ = "A" & \ GO SUB 13500 & \ GO TO 4000 IF MATCH% & 3350 GET #CH.ADD% & \ FIRST_RECORD_RFA = GETRFA ( CH.ADD% ) & \ GO TO 3340 & ! Loop thru the Mailing List File, until the first acceptable & ! address is found. Store the record's RFA & 3390 CLOSE #CH.KB% & \ OPEN "KB:" AS FILE #CH.KB%, MODE 8% & \ M11.MSG$ = "There are no addresses in this Mailing List File." & IF ERL = 3330 & \ M11.MSG$ = "There are no addresses that meet the sublist definition." & IF ERL = 3350 & \ GO SUB 14900 & \ IF M11.LIST.CODE$ = "A" THEN ERR.CODE% = MAIN.MENU% & \ GO TO 9000 & ELSE GO TO 2000 & ! Warn the user that there is nothing to print. & ! Transfer to Main Menu if there is nothing at all; & ! transfer to the list selection if there is nothing in that sublist. & 3400 CALL M11SCW(PLEASE.WAIT$,24%,1%) & \ SLEEP 2% & \ CALL M11SCW(ERASE.EOL$,24%,1%) & \ GO TO 3330 & ! Handle a locked record at 3330. & 3420 CALL M11SCW(PLEASE.WAIT$,24%,1%) & \ SLEEP 2% & \ CALL M11SCW(ERASE.EOL$,24%,1%) & \ GO TO 3350 & ! Handle a locked record at 3350. & 4000 !-------------------------------------------------------------------- & ! & ! Output Format & ! & !-------------------------------------------------------------------- & 4010 CLOSE #CH.KB% & \ OPEN "KB:" AS FILE #CH.KB%, MODE 8% & \ UNLOCK #CH.ADD% & \ GO TO 5000 IF M11.PRESORT% & 4100 CALL M11SCD (SCR.OUTPUT.FORM%) & ! Show the output format menu. & 4120 CALL M11SCR (ANS$, 18%, 39%, 1%, "S", "A", F.END%) & \ GO TO 3000 IF F.END% & ! Get the answer, clear out if 'END'. & 4140 M11.OUTPUT.FORM$ = ANS$ & \ IF POS ("SFL", ANS$, 1%) = 0% THEN & CALL M11SCD (SCR.HLP.14%) & \ M11.MSG$ = " " & \ GO SUB 14900 & \ GO TO 4100 & ! Check answer and give help if needed, or requested. & 4150 GOTO 5000 IF ANS$ = "L" CALL M11SCW ("Lines per page:", 22%, 22%) CALL M11SCR (ANS$, 22%, 39%, 3%, "66", "I", F.END%) GOTO 4100 IF F.END% IF VAL% (ANS$) < 16% THEN M11.MSG$ = BEL + "Form length must be at least 16 lines" GOSUB 14900 CALL M11SCW (ERASE.EOL$, 24%, 1%) GOTO 4150 END IF MAX.PRT.LINES% = VAL% (ANS$) ! If the output format is a short or full listing ! ask the user for form length. The default answer is 66 lines. ! ! Minimum lines per page is 16 because M11PRT prints an 8 line header ! and the first address before checking lines printed. 5000 !-------------------------------------------------------------------- & ! & ! Output Device & ! & !-------------------------------------------------------------------- & 5100 GO SUB 14000 & \ CLOSE #CH.PRT% & \ GO TO 3000 IF F.END% AND M11.PRESORT% & \ GO TO 4000 IF F.END% & ! Go show the output device options - have user pick one. & ! Check to make sure that it is ok, first. & ! Then close the file, because we may not need it for a while. & 9000 !******************************************************************** & ! & ! & ! E N D O F P R O C E S S I N G & ! & ! & !******************************************************************** & 9990 ERR.PROGNAM$ = ERR.CALLNAM$ & \ UNLOCK #CH.ADD% & \ M11.EXIT.STATUS% = TRUE% IF F.END% & \ GO TO 32767 & ! Jump around the junk and leave. & 10000 !*************************************************************** & ! & ! & ! S U B R O U T I N E S L O C A L T O & ! & ! T H I S P R O G R A M & ! & ! & !*************************************************************** & 15000 !******************************************************************** & ! & ! & ! F U N C T I O N S L O C A L T O & ! & ! T H I S P R O G R A M & ! & ! & !******************************************************************** & 19000 !******************************************************************** & ! & ! & ! S T A N D A R D E R R O R H A N D L I N G & ! & ! & !******************************************************************** & 19010 GO TO 19990 IF ERN$ <> SEG$ (ERR.PROGNAM$,1%,6%) & ! Only tracing back an error from another subprogram. & 19015 IF ERR = 154% AND (ERL = 3330% OR ERL = 3350% OR ERL = 5600%) & THEN RESUME 3400 IF ERL = 3330% & \ RESUME 3420 IF ERL = 3350% & ! Handle record locking for addresses. & 19020 RESUME 3390 IF ERL = 3330 AND ERR = 155 & \ RESUME 3390 IF ERL = 3330 AND ERR = 11 & & \ RESUME 3390 IF ERL = 3350 AND ERR = 155 & \ RESUME 3390 IF ERL = 3350 AND ERR = 11 & & & \ RESUME 2210 IF ERL = 2210 AND ERR = 154 & \ RESUME 2289 IF ERL = 2210 AND (ERR = 11 OR ERR = 155) & ! Non-fatal I/O errors against the address file. & ! Record/bucket locked (154); Record not found (155); & ! EOF on device (11). & 19900 ERR.ERL% = ERL & \ ERR.ERR% = ERR & \ ERR.CODE% = FATAL.ERROR% & ! On fatal error, set the error code. & 19990 ON ERROR GO BACK & ! Return to calling program for fatal error processing. & 32767 SUBEND