home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.barnyard.co.uk
/
2015.02.ftp.barnyard.co.uk.tar
/
ftp.barnyard.co.uk
/
cpm
/
walnut-creek-CDROM
/
CPM
/
DATABASE
/
MAIL20.ARK
/
MSETUP.INC
< prev
Wrap
Text File
|
1986-09-25
|
17KB
|
515 lines
{ File = MSETUP.INC -- Include file for Reliance Mailing List
Copyright (c) 1986 William Meacham, All Rights Reserved
Revised: 3/11/86 }
overlay procedure set_up ;
{ Get user input for available K, printer, etc. }
{ ==================== }
procedure compute_max_names ;
{ Get user input for available K, compute max names allowed.
If user escapes, reset values to what they were on entry. }
var
max_names_ok : boolean ;
i,
entry_num_k,
entry_max_rec : integer ;
k, { real of num_k }
m : real ; { real of max_rec }
begin
clrscr ;
write_str ('COMPUTE MAXIMUM NAMES ALLOWED', 26,3) ;
write_str ('How many "K" are available on drive', 8,8) ;
write (' ',drive,' ') ;
write ('for your data files?') ;
write_str ('You may have a maximum of names', 8,11) ;
write_str ('Is this satisfactory? (Y/N)', 8,13) ;
write_int (scr.num_k,4,67,8) ;
write_int (scr.max_rec,5,34,11) ;
entry_num_k := scr.num_k ;
entry_max_rec := scr.max_rec ;
fld := 1 ;
max_names_ok := false ;
repeat
case fld of
1: begin
read_int (scr.num_k,4,67,8) ; { get number of k available }
if (fld > 1) and (fld < maxint) then fld := 2
end ; { 1 }
2: begin { compute max rec, ask if ok }
if scr.num_k < 8 then
scr.max_rec := 0
else
begin
i := scr.num_k ;
if not(i mod 2 = 0) then
i := pred(i) ;
k := i ;
m := (k - 2) * 3.50 ;
{ Subtract 2K for SCR, then figure 3 1/2 data file
entries per K. Formula comes from trial and error
and is deliberately conservative. }
if m < 0.0 then
m := 0.0
else if m > 32000.0 then
m := 32000.0 ; { bullet-proofing }
scr.max_rec := trunc(m)
end ;
write_int (scr.max_rec,5, 34,11) ;
read_bool (max_names_ok,36,13)
end { 2 }
end ; {case }
if not (fld = maxint) then
if (fld < 1)
or ((fld > 2) and not (max_names_ok)) then
fld := 1
until max_names_ok or (fld = maxint) ;
if fld = maxint then
begin
scr.num_k := entry_num_k ;
scr.max_rec := entry_max_rec
end
else if not(scr.num_k = entry_num_k)
or not(scr.max_rec = entry_max_rec) then
write_scr ;
fld := 1
end ; { proc compute_max_names }
{ ==================== }
procedure set_up_printer ;
{ get initialization and reset strings for compressed print }
var
init, rset : array [1 .. 4] of integer ; { ord of chars in string }
i : integer ; { loop control }
entry_init,
entry_rset : str4 ; { values on entry to proc }
begin
clrscr ;
write_str ('SET UP YOUR PRINTER',31,2) ;
write_str ('This program prints mailing labels and lists in compressed',10,4) ;
write_str ('print. Please enter the codes needed to control your printer.',10,5) ;
write_str ('INITIALIZATION',10,7) ;
write_str ('Enter the decimal equivalents of up to four control codes',10,8) ;
write_str ('to turn ON compressed print:',10,9) ;
write_str ('==> ==> ==> ==>',10,11) ;
write_str ('RESET',10,14) ;
write_str ('Enter the decimal equivalents of up to four control codes',10,15) ;
write_str ('to turn OFF compressed print:',10,16) ;
write_str ('==> ==> ==> ==>',10,18) ;
with scr do
begin
entry_init := prt_init ;
entry_rset := prt_rset ;
for i := 1 to 4 do { initialize variables }
begin
init[i] := 0 ;
rset[i] := 0
end ;
for i := 1 to length(prt_init) do
init[i] := ord (prt_init[i]) ;
for i := 1 to length(prt_rset) do
rset[i] := ord (prt_rset[i]) ;
for i := 2 to 4 do { display vars on screen }
write_int (init[i],3,14+(9*(i-1)),11) ;
for i := 1 to 4 do
write_int (rset[i],3,14+(9*(i-1)),18) ;
fld := 1 ; { get info from user }
repeat
case fld of
1 .. 4 : read_int (init[fld],3, 14+(9*(fld-1)),11) ;
5 .. 8 : read_int (rset[fld-4],3, 14+(9*(fld-5)),18) ;
9 : pause ;
end ; { case fld of }
if fld < 1 then fld := 1
else if (fld > 99) and (fld < maxint) then fld := 9
until fld > 9 ;
if not(fld = maxint) then { update SCR only if normal exit }
begin
prt_init := '' ;
prt_rset := '' ;
for i := 1 to 4 do
begin
if not(init[i] = 0) then
prt_init := concat(prt_init,chr(init[i])) ;
if not(rset[i] = 0) then
prt_rset := concat(prt_rset,chr(rset[i]))
end ; { for i := 1 to 4 }
if not(prt_init = entry_init)
or not(prt_rset = entry_rset) then
write_scr
end { if not(fld = maxint) }
{ else (user cancelled) values remain unchanged }
end ; { with scr do }
fld := 1 { reset fld for calling routine }
end ; { proc set_up_printer }
{ ==================== }
procedure define_categories ;
var
i : integer ;
entry_cat_name : array [1..8] of str20 ;
changed : boolean ;
begin
with scr do
begin
for i := 1 to 8 do
entry_cat_name[i] := cat_name[i] ;
clrscr ;
write_str ('DEFINE SELECTION CATEGORIES',27,2) ;
write_str ('1 ',29,6) ;
write (cat_name[1]) ;
write_str ('2 ',29,7) ;
write (cat_name[2]) ;
write_str ('3 ',29,8) ;
write (cat_name[3]) ;
write_str ('4 ',29,9) ;
write (cat_name[4]) ;
write_str ('5 ',29,10) ;
write (cat_name[5]) ;
write_str ('6 ',29,11) ;
write (cat_name[6]) ;
write_str ('7 ',29,12) ;
write (cat_name[7]) ;
write_str ('8 ',29,13) ;
write (cat_name[8]) ;
fld := 1 ;
repeat
while (fld > 0) and (fld < 9) do
read_str (cat_name[fld],20,32,fld+5) ;
if fld = 9 then
pause ;
if fld < 1 then fld := 1
else if (fld > 99) and (fld < maxint) then fld := 9
until fld > 9 ;
if fld = maxint then
for i := 1 to 8 do
cat_name[i] := entry_cat_name[i]
else
begin
changed := false ;
for i := 1 to 8 do
if not(cat_name[i] = entry_cat_name[i]) then
changed := true ;
if changed then
write_scr
end
end ; { with }
fld := 1
end ; { proc define_categories }
{ ==================== }
procedure change_ID ;
{ Change descriptive file ID in SCR }
var
entryID : str30 ;
begin
clrscr ;
entryID := scr.ID ;
write_str ('CHANGE DATA FILE ID',30,2) ;
write_str ('Data file ID:',16,5) ;
repeat
fld := 1 ;
read_str (scr.ID,30,31,5) ;
if fld < 1 then fld := 1
until fld > 1 ;
if (fld < maxint)
and not (entryID = scr.ID) then
write_scr
else
scr.ID := entryID ;
fld := 1
end ; { procedure change_ID }
{ ==================== }
procedure count_names ;
label 98, 99 ;
var
tot_recs,
num_found : integer ;
ch : char ;
stop : boolean ;
which_ones : prt_criterion ;
how_to_sort : sort_criterion ;
begin
select (which_ones,how_to_sort,count) ;
if fld = maxint then goto 99 ;
if which_ones = all then
begin
num_found := scr.num_recs ;
goto 98
end ;
write_str ('Counting names . . .',31,20) ;
write_str ('Press ESC to stop ',31,21) ;
openfile (mf_file,mf_fname,sizeof(master)) ;
if not OK then
begin
show_msg (concat('CANNOT OPEN ',mf_fname)) ;
halt
end ;
num_found := 0 ;
tot_recs := filelen(mf_file) ;
rec_num := 1 ;
while rec_num < tot_recs do
begin
if keypressed then
begin
keyin (ch) ;
if ch = #$1B then
begin
write_str ('STOP NOW? (Y/N)',31,22) ;
beep ;
read_yn (stop,47,22) ;
if stop then
begin
closefile (mf_file) ;
goto 99
end
else
clrline(31,22) ;
end
end ;
getrec(mf_file,rec_num,master) ;
if master.status = 0 then
case which_ones of
pcat : if (master.flags and mask) > 0 then
num_found := succ(num_found) ;
pct : if master.precinct = pcinct then
num_found := succ(num_found) ;
pzip : if copy(master.zip,1,5) = copy(zipcode,1,5) then
num_found := succ(num_found) ;
dt : if not (greater_date(lastdt,master.last_date) = 1) then
num_found := succ(num_found) ;
amt : if not (greater(contrib,master.tot_amt)) then
num_found := succ(num_found) ;
end ; { case }
rec_num := succ(rec_num) ;
end ; { while }
closefile (mf_file) ;
98:
gotoxy (31,22) ;
write (num_found) ;
write (' records found',^G) ;
hard_pause ;
99:
fld := 1
end ; { proc count_names }
{ ==================== }
procedure display_scr ;
var
init, rset : array[1 .. 4] of integer ; { ord of chars in strings }
i : integer ;
begin
with scr do
begin
for i := 1 to 4 do
begin
init[i] := 0 ;
rset[i] := 0
end ;
for i := 1 to length(prt_init) do
init[i] := ord(prt_init[i]) ;
for i := 1 to length(prt_rset) do
rset[i] := ord(prt_rset[i]) ;
clrscr ;
write_str ('SYSTEM CONTROL INFORMATION', 28,1) ;
write_str (center(ID,30), 26,2) ;
write_str ('Today''s date:',23,4) ;
write_date (cur_proc_dt,49,4) ;
write_str ('Disk space available for data:',23,6) ;
write_int (num_k,4,55,6) ;
write (' K') ;
write_str ('Maximum names allowed:',23,8) ;
write_int (max_rec,5,54,8) ;
write_str ('Number of names used:',23,10) ;
write_int (scr.num_recs,5,54,10) ;
write_str ('Number of names left:',23,12) ;
write_int (max_rec - scr.num_recs,5,54,12) ;
write_str ('Printer:',8,14) ;
write_str ('Selection categories',45,14) ;
write_str ('Turn compressed print ON:',10,15) ;
write_str ('1 ',47,15) ;
write (cat_name[1]) ;
write_str ('2 ',47,16) ;
write (cat_name[2]) ;
for i := 1 to 4 do
if not (init[i] = 0) then
write_int (init[i],3,10+(4*(i-1)),17) ;
write_str ('3 ',47,17) ;
write (cat_name[3]) ;
write_str ('4 ',47,18) ;
write (cat_name[4]) ;
write_str ('Turn compressed print OFF:',10,19) ;
write_str ('5 ',47,19) ;
write (cat_name[5]) ;
write_str ('6 ',47,20) ;
write (cat_name[6]) ;
for i := 1 to 4 do
if not (rset[i] = 0) then
write_int (rset[i],3,10+(4*(i-1)),21) ;
write_str ('7 ',47,21) ;
write (cat_name[7]) ;
write_str ('8 ',47,22) ;
write (cat_name[8]) ;
hard_pause
end ; { with }
fld := 1
end ; { proc display_scr }
{ ==================== }
procedure print_scr ;
var
ch : char ;
st : str80 ;
dt : datestring ;
i : integer ;
begin
write_str ('PUT PLAIN PAPER IN THE PRINTER',22,23) ;
write_str ('PRESS SPACE BAR TO CONTINUE OR ESC TO CANCEL',22,24) ;
repeat
keyin (ch)
until (ch in [' ',#$1B]) ;
if ch = ' ' then { print the report }
begin
write (lst,scr.prt_rset) ;
st:= '' ;
add_blanks (st,12) ;
writeln (lst,concat(st,'RELIANCE MAILING LIST SYSTEM CONTROL INFORMATION')) ;
writeln(lst) ;
st := 'Data file ID:' ;
add_blanks (st,13) ;
writeln(lst,concat(st,scr.ID)) ;
writeln(lst) ;
st := 'Today''s date:' ;
add_blanks (st,13) ;
dt := mk_dt_st (cur_proc_dt) ;
writeln (lst,concat(st,dt)) ;
writeln(lst) ;
write (lst,'Disk space available for data: ') ;
write (lst,scr.num_k:5) ;
writeln (lst,' K') ;
writeln (lst) ;
st := 'Maximum names allowed:' ;
add_blanks (st,9) ;
write (lst,st) ;
writeln (lst,scr.max_rec:5) ;
writeln (lst) ;
st := 'Number of names used:' ;
add_blanks (st,10) ;
write (lst,st) ;
writeln (lst,scr.num_recs:5) ;
writeln (lst) ;
st := 'Number of names left:' ;
add_blanks (st,10) ;
write (lst,st) ;
writeln (lst,scr.max_rec - scr.num_recs:5) ;
writeln (lst) ;
writeln (lst,'Printer:') ;
write (lst,' Turn compressed print ON: ') ;
i := 1 ;
while i <= length(scr.prt_init) do
begin
write (lst,ord(scr.prt_init[i]):4) ;
i := succ(i)
end ;
writeln (lst) ;
writeln (lst) ;
write (lst,' Turn compressed print OFF: ') ;
i := 1 ;
while i <= length(scr.prt_rset) do
begin
write (lst,ord(scr.prt_rset[i]):4) ;
i := succ(i)
end ;
writeln (lst) ;
writeln (lst) ;
writeln (lst,'Selection categories:') ;
for i := 1 to 8 do
begin
write (lst,' ') ;
write (lst,i) ;
writeln (lst,concat(' ',scr.cat_name[i]))
end ;
page (lst)
end { if ch = ' ' }
end ; { proc print_scr }
{ ==================== }
begin { proc set_up ------------------------ }
repeat
clrscr ;
write_str ('SET-UP MENU', 35,1) ;
write_str ('Please select:', 22,3) ;
write_str ('1 Compute maximum names allowed', 22,5) ;
write_str ('2 Set up your printer', 22,7) ;
write_str ('3 Define selection categories', 22,9) ;
write_str ('4 Change data file ID',22,11) ;
write_str ('5 Count names used', 22,13) ;
write_str ('6 Display system control information', 22,15) ;
write_str ('7 Print system control information', 22,17) ;
write_str ('ESC Return to Main Menu', 22,19) ;
write_str ('==>', 22,21) ;
repeat
fld := 1 ;
choice := 0 ;
read_int (choice,1, 27,21) ;
if fld < 1 then choice := 0
until (choice in [1 .. 7]) or (fld = maxint) ;
if not (fld = maxint) then
case choice of
1: compute_max_names ;
2: set_up_printer ;
3: define_categories ;
4: change_ID ;
5: count_names ;
6: display_scr ;
7: print_scr
else
beep
end ; { case }
until fld = maxint ;
fld := 1
end ; { proc set_up }
{ -------- EOF MSETUP.INC ----------------------------------- }
str ('4 Change data file ID',22,11) ;
write_str ('5 Count names used', 22,13) ;