perm filename SENDER.SAI[MNT,CSR] blob
sn#229923 filedate 1976-08-11 generic text, type C, neo UTF8
COMMENT ⊗ VALID 00007 PAGES
C REC PAGE DESCRIPTION
C00001 00001
C00002 00002 SENDER - the declarations
C00006 00003 ORDER procedure
C00010 00004 INVOICE procedure
C00018 00005 SENDER runs - the set up
C00022 00006 SENDER runs - the run loop
C00027 00007 SENDER runs - the wrap up
C00030 ENDMK
C⊗;
COMMENT SENDER - the declarations;
BEGIN
EXTERNAL PROCEDURE BAIL;
REAL PRICER,TAX,TAXTOL,OWE,TOTAL,R1,BASE;
BOOLEAN EOF,FLAG,EF1,UP,ALOOK,BLOOK,CLOOK,INSTOC,NOSTOC,LP,LLP;
INTEGER C1,C2,PL,COUNT,DSKCT,BRCHAR,NUMBER,JMP,REC,PG,C3,C4,C5;
INTEGER I,J,K,REPORTS,ORDERS,OREC,DUM,NOOR,DAT;
INTEGER LINELB,LINEST,COPIES,NOW,ZIP,CHARGE;
STRING TYPEIN,STT,PAGE,LINE,HEADER,HASH,PAT,DATA,MONTH,ESTRING,TAGE,ORDTIT,NOORTIT,S1,RAND,LINER,DATE;
STRING ARRAY ADDRESS[0:5];
REQUIRE 20000 STRING_SPACE;
REQUIRE "⊂⊃" DELIMITERS;
DEFINE CRLF=⊂'15&'12⊃;
DEFINE PRT=⊂PRINT(CRLF⊃;
DEFINE PRTERR=⊂PRT,"The legal responses are:",CRLF,CRLF⊃;
DEFINE RET=⊂IF EQU(TYPEIN[1 TO 1],'15) THEN⊃;
DEFINE TTIN=⊂CLRBUF; TYPEIN←TTYINL(1,BRCHAR); WHILE EQU(TYPEIN[1 TO 1]," ")
DO DUM←LOP(TYPEIN);⊃;
DEFINE SCIN=⊂LINE←SCAN(PAGE,1,BRCHAR);⊃;
DEFINE PGIN=⊂USETI(C3,I); PAGE←INPUT(C3,2);
WHILE LENGTH(PAGE)<5 DO PAGE←INPUT(C3,2);⊃;
DEFINE QUEST=⊂IF (EQU(TYPEIN[1 TO 1],"?")) OR (EQU(TYPEIN[1 TO 4],"HELP")) THEN BEGIN
PRTERR, " ?<cr> WILL PRINT YOUR OPTIONS",CRLF,
" HELP<cr> WILL PROVIDE SOME HELP",CRLF,
" <cr> "⊃;
DEFINE HELP=⊂PRT,
"HELP FOR THE SENDER PROGRAM: ",CRLF,
" The sender program is designed to produce an invoice for ",CRLF,
"orders made by people who are not in the address file. It will",CRLF,
"also keep track of the inventory level. The program uses the ",CRLF,
"reports that are in the REPTFL.DSK data file, which is updated ",CRLF,
"after the normal mailing by CSMAIL. If you wish to send late ",CRLF,
"copies to an individual who is in the address file, you will ",CRLF,
"have to update the amount of money that he owes by useing the ",CRLF,
"LISTUP porgram. ",CRLF,
" he program will also dump the name, address, and the reports",CRLF,
"that are ordered by each individual into a file called RANDOM.DSK.",CRLF,
"This is only for informational purposes, and will not be used by ",CRLF,
"the REPORT system. ",CRLF,
" The program runs in a loop allowing you to input the address,",CRLF,
"followed by the reports that were ordered one at a time. If a ",CRLF,
"report cannot be found, or it is out of stock the invoice will ",CRLF,
"so state, otherwise the customer will be charged if he is not a",CRLF,
"free user.");⊃;
DEFINE CALIF=⊂IF ZIP=1 THEN ⊃;
COMMENT ORDER procedure;
SIMPLE PROCEDURE ORDER;
BEGIN
COMMENT this procedure will allow the user to request reports to be included
for the person whose address has been input. If the report is out of
stock, or it is not in the file it will ce flaged as such, otherwise
it will be included in the invoice;
STRING SAV;
INTEGER AA,BB;
REAL PRICE;
BOOLEAN FOUND;
INSTOC←NOSTOC←FALSE; ORDTIT←NOORTIT←""; ORDERS←NOOR←TOTAL←0;
COMMENT this is the report gathering loop;
WHILE BLOOK DO
BEGIN
PRT,"Report title or <cr> if finished *"); TTIN; RET DONE;
IF EQU(TYPEIN[1 TO 4],"HELP") THEN
PRT," The name is the Stanford or AI name that is used to catelog",crlf,
"reports (i.e. STAN-76-CS-654 or AIM-432). If the report is ",crlf,
"found it will be included, otherwise the customer will be informed",crlf,
"that it is out of stock");
QUEST,"WILL CAUSE THE INVOICE TO BE WRITTEN.",CRLF,
"<reoort><cr> THE OFFICAL NAME OF A REPORT THAT WAS ORDERED.");
CONTINUE; END;
COMMENT porcess the report once it has been received;
ORDERS←ORDERS+1; SETFORMAT(-4,2);
TYPEIN←TYPEIN[1 TO LENGTH(TYPEIN)-1];
WHILE CLOOK DO
BEGIN
FOUND←FALSE; SAV←"";
FOR I←1 STEP 1 UNTIL REPORTS DO
BEGIN
LINE←SCAN(DATA,1,BRCHAR);
IF EQU(LINE[2 TO LENGTH(TYPEIN)+1],TYPEIN) THEN
BEGIN
IF EQU(LINE[LENGTH(TYPEIN)+5 TO LENGTH(TYPEIN)+8],"NONO") THEN AA←10000 ELSE
AA←CVD(LINE[LENGTH(TYPEIN)+5 TO LENGTH(TYPEIN)+8]);
BB←CVD(LINE[LENGTH(TYPEIN)+10 TO LENGTH(TYPEIN)+13]);
IF AA>0 THEN
BEGIN
INSTOC←TRUE;
SAV←SAV&"*"&TYPEIN&"|";
DO TYPEIN←TYPEIN&" " UNTIL LENGTH(TYPEIN)≥35;
ORDTIT←ORDTIT&TYPEIN;
ESTRING←SCAN(LINE,8,BRCHAR);
TYPEIN←LINE[13 TO 17]&'12;
PRICE←REALSCAN(TYPEIN,BRCHAR);
TOTAL←TOTAL+PRICE;
ORDTIT←ORDTIT&CVF(PRICE)&'15&'12;
IF AA>9000 THEN
SAV←SAV&LINE[1 TO 2]&"NONO,"&CVS(BB+1)&LINE[12 TO 200]&'12 ELSE
SAV←SAV&LINE[1 TO 2]&CVS(AA-1)&","&CVS(BB+1)&LINE[12 TO 200]&'12;
FOUND←TRUE;
DONE;
END; END;
SAV←SAV&LINE&'12;
END;
SAV←SAV&DATA; DATA←SAV;
IF FOUND THEN DONE;
PRT,"REPORT OUT OF STOCK");
NOSTOC←TRUE; NOOR←NOOR+1;
NOORTIT←NOORTIT&TYPEIN&'15&'12;
DONE;
END; END; END;
COMMENT INVOICE procedure;
SIMPLE PROCEDURE INVOICE;
BEGIN "INVOICE"
COMMENT this procedure will produce the invoice using the template on
page three of the data base file LBDATA;
INTEGER CTT;
STRING SAVER,DUMP,SPACE,BACK,STR,STS,BUM;
REAL X,TX;
DEFINE SC8=⊂STR←SCAN(STT,8,BRCHAR);⊃;
DEFINE SC9=⊂STS←SCAN(STT,9,BRCHAR);⊃;
SAVER←""; SPACE←" "; SCIN;
IF CHARGE=0 THEN TOTAL←0;
COMMENT now build the invoice;
STT←TAGE; CTT←0; SC9; SC8;
SAVER←STS&ADDRESS[1]&STR;
COMMENT insert the paragraph for documents we are forwarding;
IF NOT INSTOC THEN BEGIN SC8 END ELSE
BEGIN
SC9; SAVER←SAVER&STS&"report";
SC9; SAVER←SAVER&STS;
FOR J←1 STEP 1 UNTIL ORDERS-NOOR DO
BEGIN
TYPEIN←SCAN(ORDTIT,1,BRCHAR); TYPEIN←TYPEIN&'12;
SAVER←SAVER&SPACE&TYPEIN;
END;
CALIF TAXTOL←TAXTOL+TOTAL*TAX*(100/(100+TAX));
SC9; SC8;
SAVER←SAVER&STS&CVF(TOTAL)&STR;
END;
COMMENT this section will insert the paragraph for documents that are
out of stock if any are;
IF NOT NOSTOC THEN BEGIN SC8 END ELSE
BEGIN
SC9; SAVER←SAVER&STS&"report";
SC9; SAVER←SAVER&STS;
FOR J←1 STEP 1 UNTIL NOOR DO
BEGIN
TYPEIN←SCAN(NOORTIT,1,BRCHAR); TYPEIN←TYPEIN&'12;
SAVER←SAVER&SPACE&TYPEIN;
END;
SC8; SAVER←SAVER&STR;
END;
COMMENT compute the invoice;
SC9; ESTRING←STS; SC9; BUM←STS; SC9;
CALIF SAVER←SAVER&ESTRING&"REPORT"&BUM&CVF(TOTAL)&" INCLUDING TAX"&STS ELSE
SAVER←SAVER&ESTRING&"REPORT"&BUM&CVF(TOTAL)&STS;
SAVER←SAVER[1 TO LENGTH(SAVER)-2]&'15&'12;
FOR J←1 STEP 1 UNTIL 5 DO SAVER←SAVER&ADDRESS[J];
SC9; BUM←STS; SC9;
SAVER←SAVER&BUM&PAT&STS&'14;
OUT(C3,SAVER); SAVER←"";
END "INVOICE";
COMMENT SENDER runs - the set up;
SETBREAK(1,'12,NULL,"IKP");
SETBREAK(2,'14,NULL,"IAP");
SETBREAK(3,'15,NULL,"IAP");
SETBREAK(4,'113,NULL,"IAP");
SETBREAK(5,'136,NULL,"IAP");
SETBREAK(6,'117,NULL,"IAP");
SETBREAK(7,'54,NULL,"IAP");
SETBREAK(8,'174,NULL,"IP");
SETBREAK(9,'52,NULL,"IP");
SETBREAK(10,'56,NULL,"IP");
SETBREAK(11,'52&'14,NULL,"IAP");
SETBREAK(12,'12,NULL,"IAP");
SETBREAK(13,'54&'174,NULL,"IP");
SETBREAK(14,'77,NULL,"IAP");
COMMENT Open the I/O channels;
OPEN(C1←GETCHAN,"TTY",0,2,2,COUNT,BRCHAR,EOF);
OPEN(C2←GETCHAN,"DSK",0,2,0,DSKCT,BRCHAR,EF1);
OPEN(C3←GETCHAN,"DSK",0,2,2,DSKCT,BRCHAR,EF1);
OPEN(C4←GETCHAN,"DSK",0,2,2,DSKCT,BRCHAR,EF1);
OPEN(C5←GETCHAN,"DSK",0,2,2,DSKCT,BRCHAR,EF1);
COMMENT Set the run parameters;
COUNT←100;
DSKCT←40000;
LOOKUP(C3,"LBDATA.DSK",FLAG);
ENTER(C3,"LBDATA.DSK",FLAG); I←0;
DO BEGIN I←I+1; PGIN; END UNTIL EQU(PAGE[1 TO 4],"DATA");
I←CVD(PAGE[6 TO 6]); SCIN;
FOR J←1 STEP 1 UNTIL I DO
BEGIN
SCIN; DO DUM←LOP(LINE) UNTIL EQU(LINE[1 TO 1],"="); DUM←LOP(LINE);
STT←""; DO BEGIN STT←STT&LINE[1 TO 1]; DUM←LOP(LINE); END
UNTIL EQU(LINE[1 TO 1]," ");
CASE J-1 OF
BEGIN
BASE←REALSCAN(STT,BRCHAR);
PRICER←REALSCAN(STT,BRCHAR);
DAT←CVD(STT);
COPIES←CVD(STT);
LINELB←CVD(STT);
LINEST←CVD(STT);
PAT←STT&LINE[1 TO 15];
OWE←REALSCAN(STT,BRCHAR);
END;
END;
TAX←DAT/1000.0; TAXTOL←0;
SETFORMAT(-4,2);
COMMENT read in the stock;
CLOSE(C5); CLOSE(C4); CLOSE(C3);
LOOKUP(C4,"REPTFL.DSK",FLAG); USETI(C4,0);
DO PAGE←INPUT(C4,2) UNTIL PAGE[1 TO 1]≤'71 AND PAGE[1 TO 1]≥'60;
SCIN; REPORTS←CVD(LINE[1 TO LENGTH(LINE)-1]); DATA←"";
IF REPORTS>0 THEN
FOR J←1 STEP 1 UNTIL REPORTS DO BEGIN SCIN; DATA←DATA&LINE&'12; END;
CLOSE(C5); CLOSE(C4); LOOKUP(C4,"LBDATA.DSK",FLAG); USETI(C4,1);
DO TAGE←INPUT(C4,2) UNTIL EQU(TAGE[1 TO 6],"INVOIC"); CLOSE(C4);
ALOOK←BLOOK←CLOOK←TRUE;
WHILE BLOOK DO
BEGIN
PRT,"Enter the date to send these orders *");
TTIN;
IF EQU(TYPEIN[1 TO 4],"HELP") THEN
PRT," This is to put in the RANDOM.DSK dump file so that you will be able to check when it was mailed");
QUEST,"WILL CAUSE THE PROGRAM TO REPEAT THE QUESTION.",CRLF,
"<date><cr> WILL ACCEPT ANY INPUT AS THE DATE.");
CONTINUE; END;
DATE←TYPEIN[1 TO LENGTH(TYPEIN)-1];
DONE;
END;
COMMENT SENDER runs - the run loop;
CLOSE(C3); LOOKUP(C5,"INVOIC",FLAG); ENTER(C3,"INVOIC",FLAG); USETO(C3,1);
WHILE ALOOK DO
BEGIN
PRT,"SENDER - Enter name or <cr> to exit *");
TTIN; RET DONE;
IF EQU(TYPEIN[1 TO 4],"HELP") THEN HELP;
QUEST,"WILL CAUSE THE PROGRAM TO EXIT",CRLF,
"<name<<cr> THE FIRST LINE OF THE ADDRESS FOR THIS ORDER");
CONTINUE; END;
ADDRESS[1]←TYPEIN&'12; SETFORMAT(1,1);
FOR I←1 STEP 1 UNTIL 4 DO
BEGIN
PRT,"Enter line ",CVS(I)," of the address *");
TTIN; ADDRESS[I+1]←"";
IF EQU(TYPEIN[1 TO 4],"HELP") THEN
PRT," You are allowed to use up to five lines for the address",crlf,
"field, including the name line. These lines should contain",crlf,
"no more then 34 characters, and can be left blank.");
QUEST,"WILL CAUSE A BLANK LINE TO BE USED IN THE ADDRESS",CRLF,
"<line><cr> THE ",CVS(I)," LINE OF THE ADDRESS FOR THIS ORDER");
I←I-1;
CONTINUE; END;
ADDRESS[I+1]←TYPEIN&'12;
END;
WHILE BLOOK DO
BEGIN
PRT,"Is the customer to be charged for reports (Y or N)? *");
TTIN;
IF EQU(TYPEIN[1 TO 1],"Y") THEN BEGIN CHARGE←1; DONE; END;
IF EQU(TYPEIN[1 TO 1],"N") THEN BEGIN CHARGE←0; DONE; END;
IF EQU(TYPEIN[1 TO 4],"HELP") THEN
PRT," This is to allow the flexibility of not charging certain categories ",crlf,
"of customers.");
QUEST,"WILL CAUSE THE PROGRAM TO REPEAT THE QUESTION.",CRLF,
" Y<cr> THE CUSTOMER WILL BE CHARGED FOR REPORTS THAT ARE SENT.",CRLF,
" N<cr> NO CHARGE WILL BE MADE FOR REPORTS.");
CONTINUE; END;
RET CONTINUE;
END;
IF CHARGE=1 THEN
WHILE CLOOK DO
BEGIN
PRT,"Is this order to be sent to someone within California (Y or N)? *");
TTIN;
IF EQU(TYPEIN[1 TO 1],"Y") THEN BEGIN ZIP←1; DONE; END;
IF EQU(TYPEIN[1 TO 1],"N") THEN BEGIN ZIP←0; DONE; END;
IF EQU(TYPEIN[1 TO 4],"HELP") THEN
PRT," Tax is only calculted for customers who reside in California.",crlf,
"This information doess not apply to customers whose billing",crlf,
"code is free.");
QUEST,"WILL CAUSE THE PROGRAM TO REPEAT THE QUESTION.",CRLF,
" Y<cr> TAX WILL BE CALCULATED FOR REPORTS THAT ARE SENT.",CRLF,
" N<cr> NO TAX WILL BE CHARGED.");
CONTINUE; END;
RET CONTINUE;
END;
ORDERS←0;
ORDER;
RAND←ORDTIT;
IF NOSTOC THEN RAND←RAND&" OUT OF STOCK"&'15&'12&NOORTIT;
IF ORDERS>0 THEN INVOICE;
IF ORDERS>0 THEN
BEGIN
CLOSE(C5); CLOSE(C4);
LOOKUP(C4,"RANDOM.DSK",FLAG); USETI(C4,0);
ENTER(C5,"RANDOM.DSK",FLAG); USETO(C5,0);
DO PAGE←INPUT(C4,2) UNTIL EQU(PAGE[1 TO 4],"LATE");
SCIN; STT←LINE&'12;
WHILE BLOOK DO
BEGIN
SCIN;
IF EQU(LINE[1 TO 3],"END") THEN DONE;
STT←STT&LINE&'12;
END;
STT←STT&"XXXXXXXXXXXXXXX "&DATE&" XXXXXXXXXXXXXXX"&'15&'12;
LINER←STT&ADDRESS[1]&ADDRESS[2]&ADDRESS[3]&ADDRESS[4]&ADDRESS[5]&RAND&"END"&'15&'12;
OUT(C5,LINER);
END;
END;
COMMENT SENDER runs - the wrap up;
COMMENT now read the REPTFL file back to disk, and exit;
CLOSE(C5); CLOSE(C4);
LOOKUP(C4,"REPTFL.DSK",FLAG); USETI(C4,0);
ENTER(C5,"REPTFL.DSK",FLAG); USETO(C5,0);
STT←CVS(REPORTS)&'15&'12;
DATA←STT&DATA&'14;
OUT(C5,DATA);
CLOSE(C1); CLOSE(C2); CLOSE(C3); CLOSE(C4); CLOSE(C5);
PRT,"GOODBYE - Your invoices are in INVOICE - Have a nice day.");
END;