|
25 Years of Programming
An open source source for C, C++, OWL, BASIC, MDB, XLS, DOT, and more... |
Home Projects Up Sitemap Search Blog Forum+Chat About Us Privacy Terms of Use Feedback FAQ Images Services Ads Donate Humor |
Heathkit H89 Microsoft MBASIC program to tabulate who should be
billed for the charges on your telephone bill.
PHONTALY This program is for professionals or others who incur each month substantial phone charges that are distributed among a large number of phone numbers, and that must subsequently be billed out to clients. To use the program, you must first input the phone numbers from your Rolodex files, following the instructions given in the program. Once you become comfortable with the program, a faster way to manipulate the files is to do it directly with the CP/M editor (ED) or with WordStar or with any other CP/M compatible word processing system. You should note that all entries in the PHONNOS.DAT file are enclosed by quotation marks and separated by commas, a format that must be preserved for proper program operation. That is, the format must be: "phone number","client #" . The 'client number' does not have to be a number. It can be a name. However, if a name is used then it will appear on the output at the top of the list, that is, not in order with the rest of the client numbers. Each month, when you receive your phone bill, you should run this program. Input the phone numbers appearing on the bill in the order in which they appear. Then, input, in the same order, the charges that correspond to each number. The program will then accumulate for each PHONE NUMBER the total charges attributable to it. It will then look up each phone number in your client file and assign the client number to the charges. Lastly, it will output, in order of ascending client number, the clients to bill, the amounts to bill them, and, for reference, the phone numbers which correspond to the charges. Several files are kept by the program. Most are written over each time the program is run. PHONNOS.DAT is the only permanent file. It contains your list of phone numbers and the associated client numbers. SCRATCH.DAT is a temporary file used when editing the file PHONNOS.DAT. RAW.DAT holds the raw phone bill information. KNOWN.DAT holds the list of phone numbers, charges, and client numbers that were identified, while UNKNOWN.DAT holds the ones that could not be identified. This program requires the use of a printer. If a printer is not to be used, then all LPRINT statements in the program must be changed to PRINT statements. It is up to you whether to use area codes with the program. If you input them to the client list, then you must also do so when entering the phone numbers each month. Generally, the chances that two numbers will be identical except for the area code are very small, so the area codes are not really necessary. Using them slows down input considerably. Whenever referencing phone numbers, you must be consistent. If you input 555-1212, the program will not find it if the file contains '5551212'. It is good policy to use no characters except for the numerals: (408)555-1212=4085551212. 10 REM PHONTALY.BAS 11 'COPYRIGHT (C)1982 STEVEN WHITNEY. 12 'Published under GNU GPL (General Public License) Version 2, with ABSOLUTELY NO WARRANTY. 13 'Initially published by http://25yearsofprogramming.com. 20 ON ERROR GOTO 960 30 FM1$="###.##" : FM2$="##########" 40 PRINT CHR$(27)"E" 50 PRINT "IF NOT ALREADY DONE, PLEASE SET YOUR KEYBOARD TO 'CAPS LOCK.'":PRINT "ALL YOUR RESPONSES MUST BE CAPITAL LETTERS.":PRINT STRING$(75,"=") 60 PRINT "Press Any Key to Continue":Z$=INPUT$(1) 70 REM MENU 80 PRINT CHR$(27)"E":PRINT STRING$(75,"="):PRINT:PRINT" Phone Billing Program Menu ":PRINT STRING$(75,"-") 90 PRINT 100 PRINT "1 = Make changes to the list of phone and client numbers." 110 PRINT 120 PRINT "2 = Enter phone bill information and print a report." 130 PRINT 140 PRINT "3 = Exit to operating system." 150 PRINT:PRINT:PRINT STRING$(75,"-") 160 PRINT "Which do you want to do (1,2,3)?";:Z$=INPUT$(1):PRINT Z$ 170 IF Z$="1" THEN 210 180 IF Z$="2" THEN 1060 190 IF Z$="3" THEN SYSTEM 200 IF VAL(Z$)<1 OR VAL(Z$)>3 THEN 80 210 PRINT CHR$(27)"E";"These routines for file manipulation are very slow. If you have access to":PRINT "the WordStar word processing system, or know how to use the CP/M context":PRINT "editor (ED), then you can increase the speed of this function by" 220 PRINT "using those routines. Information about file structure is in 'PHONTALY.DOC'.":PRINT:PRINT "Press Any Key to Continue":Z$=INPUT$(1) 230 PRINT CHR$(27)"E";:PRINT:PRINT:PRINT"File Change Menu";STRING$(75,"-"):PRINT 240 PRINT 250 PRINT "1 = Add phone and client numbers to the file." 260 PRINT 270 PRINT "2 = Delete phone and client numbers from the file." 280 PRINT 290 PRINT "3 = Return to main menu." 300 PRINT:PRINT:PRINT STRING$(75,"-") 310 PRINT "Which do you want to do (1,2,3)? ";:Z$=INPUT$(1):PRINT Z$ 320 IF Z$="1" THEN 360 330 IF Z$="2" THEN 550 340 IF Z$="3" THEN 80 350 IF VAL(Z$)<1 OR VAL(Z$)>3 THEN 310 360 REM ADD 370 OPEN "I",1,"PHONNOS.DAT" 380 OPEN "O",2,"SCRATCH.DAT" 390 WHILE NOT EOF(1) 400 INPUT #1,A$,B$ 410 WRITE #2,A$,B$ 420 WEND 430 PRINT 440 T=-1 450 T=T+1 : IF T/10=INT(T/10) THEN PRINT,,"==> To end, enter '0' for phone #." 460 PRINT:INPUT "Phone number to add ";A$ 470 IF A$="0" THEN 510 480 INPUT "Client number to add";B$ 490 WRITE #2,A$,B$ 500 GOTO 450 510 CLOSE 520 KILL "PHONNOS.DAT" 530 NAME "SCRATCH.DAT" AS "PHONNOS.DAT" 540 GOTO 230 550 REM DELETE 560 PRINT CHR$(27)"E":PRINT:PRINT:PRINT:PRINT:PRINT STRING$(75,"="):PRINT,, "Deletion Menu";STRING$(75,"-"):PRINT 570 PRINT "1 = Search for a PHONE NUMBER and delete it." 580 PRINT 590 PRINT "2 = Search for, and delete, all references to a particular CLIENT." 600 PRINT 610 PRINT "3 = Return to previous menu." 620 PRINT:PRINT:PRINT STRING$(75,"-") 630 PRINT "Which do you want to do? (1,2,3)";:Z$=INPUT$(1):PRINT Z$ 640 IF Z$="1" THEN 680 650 IF Z$="2" THEN 820 660 IF Z$="3" THEN 230 670 IF VAL(Z$)<1 OR VAL(Z$)>3 THEN 630 680 REM DELETE BY PHONE NUMBER 690 PRINT:INPUT "Which phone number to delete";C$ 700 OPEN "I",1,"PHONNOS.DAT" 710 OPEN "O",2,"SCRATCH.DAT" 720 WHILE NOT EOF(1) 730 INPUT #1,A$,B$ 740 IF A$<>C$ THEN WRITE #2,A$,B$ 750 WEND 760 CLOSE 770 KILL "PHONNOS.DAT" 780 NAME "SCRATCH.DAT" AS "PHONNOS.DAT" 790 PRINT "Delete another (Y/N)?";:Z$=INPUT$(1):PRINT Z$ 800 IF Z$<>"Y" AND Z$<>"N" THEN 790 810 IF Z$="Y" THEN 690 ELSE 550 820 REM DELETE BY CLIENT # 830 PRINT:INPUT "Which client # to delete";C$ 840 OPEN "I",1,"PHONNOS.DAT" 850 OPEN "O",2,"SCRATCH.DAT" 860 WHILE NOT EOF(1) 870 INPUT #1,A$,B$ 880 IF B$<>C$ THEN WRITE #2,A$,B$ 890 WEND 900 CLOSE 910 KILL "PHONNOS.DAT" 920 NAME "SCRATCH.DAT" AS "PHONNOS.DAT" 930 PRINT:PRINT "Delete another? (Y/N)";:Z$=INPUT$(1):PRINT Z$ 940 IF Z$<>"Y" AND Z$<>"N" THEN 930 950 IF Z$="Y" THEN 820 ELSE 550 960 IF ERR=53 THEN PRINT "Is this the first time you have EVER run this program? (Y/N)";:Z$=INPUT$(1):PRINT Z$ 970 IF Z$<>"Y" AND Z$<>"N" THEN 960 980 IF Z$="N" THEN 1040 990 PRINT "THAT MEANS YOU HAVE NEVER ENTERED PHONE NUMBERS AND CLIENT NUMBERS INTO THE":PRINT "SYSTEM, OR YOU WANT TO START AGAIN, COMPLETELY FROM SCRATCH.":PRINT" IS THIS CORRECT (Y/N)?";:Z$=INPUT$(1):PRINT Z$ 1000 IF Z$<>"Y" AND Z$<>"N" THEN 990 1010 IF Z$="N" THEN 1040 1020 PRINT "Initializing system. Wait a moment, please..." 1030 OPEN "O",1,"PHONNOS.DAT":CLOSE:RESUME 1040 PRINT "AN ERROR WAS ENCOUNTERED. PLEASE CONSULT YOUR BASIC-80 MANUAL REGARDING THE ":PRINT "FOLLOWING ERROR MESSAGE. THE ERROR OCCURRED AT PROGRAM LINE #";ERL 1050 CLOSE : ON ERROR GOTO 0 1060 REM PROGRAM NAME 'PHONTALY' 1070 PRINT CHR$(27)"E";"This program asks you to input from your phone bill all the phone numbers and":PRINT "corresponding charges that appear. After that, it is on its own. It will" 1080 PRINT "eventually output a list, in ascending numerical order, of your clients to":PRINT"bill, the amounts to bill them, and the phone number that is associated ":PRINT"with each charge." 1090 PRINT STRING$(75,"=") 1100 PRINT "Make sure your printer is on. Press any key to continue.":Z$=INPUT$(1) 1110 INPUT "Who is this analysis for (any format ok)";CN$ 1120 INPUT "What is the date on the phone bill (any format ok)";DATE$ 1130 LPRINT TAB(20);CN$ : LPRINT TAB(20)"Analysis of phone bill dated: ";DATE$ 1140 LPRINT STRING$(75,"-") 1150 PRINT STRING$(75,"-") 1160 OPEN "O",1,"RAW.DAT" 1170 DIM A$(300),B(300) 1180 PRINT "First input the phone numbers:":PRINT 1190 I=-1 1200 I=I+1 1210 IF I/10=INT(I/10) THEN PRINT,,"==> '0' signals data end.":PRINT,,"==> '-1' backs up one entry." 1220 INPUT "Phone number? ",A$(I) 1230 IF A$(I)="0" THEN 1270 1240 IF A$(I)="-1" THEN PRINT "Was: ";A$(I-1);" New ";: I=I-1 : GOTO 1220 1250 IF LEN(A$(I))<>7 AND LEN(A$(I))<>10 THEN PRINT CHR$(7)"Error Caught - Enter again":GOTO 1220 1260 GOTO 1200 1270 PRINT STRING$(75,"-"):PRINT "Now, input the corresponding $ amounts, in the same order:":PRINT 1280 I=-1 1290 I=I+1 1300 IF I/10=INT(I/10) THEN PRINT,,"==> '0' signals data end.":PRINT,,"==> '-1' backs up one entry." 1310 PRINT A$(I), 1320 INPUT "Amount";A 1330 IF A=-1 THEN PRINT "Error Routine":I=I-1 : GOTO 1310 1340 B(I)=A/100 1350 REM IF LAST ELEMENT, BRANCH TO PRINT LIST TO VERIFY 1360 IF A$(I)="0" AND B(I)=0 THEN 1380 1370 GOTO 1290 1380 PRINT STRING$(75,"-"):PRINT "Recap of Data":PRINT TAB(20)"PHONE NUMBER";TAB(40)"AMOUNT":GOSUB 1580 1390 PRINT:PRINT,,"*** SYSTEM WORKING ***" 1400 FOR I=0 TO B-1 1410 REM DOUBLE LOOP TO CONSOLIDATE AMOUNTS INTO SINGLE ACCOUNTS 1420 IF A$(I)="0" THEN 1480 : REM- SKIP ONES ALREADY DONE 1430 FOR J=(I+1) TO B 1440 IF A$(J)=A$(I) THEN 1460 1450 GOTO 1470 1460 GOSUB 1510 1470 NEXT J 1480 NEXT I 1490 X=1 : REM SET COUNTER FOR VERIFICATION LIST 1500 PRINT STRING$(75,"-"):PRINT "Consolidated Data Recap":PRINT TAB(20)"PHONE NUMBER";TAB(40)"AMOUNT":GOSUB 1580 1510 B(I)=B(I)+B(J) 1520 REM SET ALREADY DONE ENTRIES TO ZERO SO THEY WONT BE COUNTED AGAIN 1530 B(J)=0 1540 A$(J)="0" 1550 RETURN 1560 CLOSE 1570 GOTO 1670 1580 B=I 1590 PRINT:PRINT:PRINT 1600 FOR J=0 TO B : REM PRINT COMPLETE LIST TO CHECK IT 1610 PRINT TAB(20);USING FM2$;VAL(A$(J));:PRINT TAB(40);USING FM1$;B(J) 1620 IF X=1 AND A$(J)<>"0" THEN WRITE #1,A$(J),B(J) 1630 REM LPRINT ROUTINE CAN GO HERE 1640 NEXT J 1650 IF X=1 THEN 1560 1660 RETURN 1670 ERASE A$,B: DIM A$(300),B$(300),C$(300),X$(100),Y$(100),Z$(100) 1680 PRINT 1690 OPEN "I",1,"PHONNOS.DAT" 1700 WHILE NOT EOF(1) 1710 INPUT #1,A$(I),B$(I) 1720 I=I+1 1730 WEND 1740 CLOSE 1750 OPEN "I",1,"RAW.DAT" 1760 OPEN "O",2,"KNOWN.DAT" 1770 OPEN "O",3,"UNKNOWN.DAT" 1780 WHILE NOT EOF(1) 1790 INPUT #1,C$,E$ 1800 FOR J=0 TO I-1 1810 IF A$(J)<>C$ THEN 1840 1820 WRITE #2,B$(J),C$,E$ 1830 GOTO 1780 1840 NEXT J 1850 WRITE #3,C$,E$ 1860 WEND 1870 CLOSE 1880 ERASE A$,B$:DIM A$(300),B$(300) 1890 REM ORDER BY CLIENT # 1900 OPEN "I",1,"KNOWN.DAT" 1910 WHILE NOT EOF(1) 1920 INPUT #1,A$(K),B$(K),C$(K) 1930 K=K+1 1940 WEND 1950 CLOSE 1960 REM PUT IN NUMERICAL ORDER 1970 FOR L=0 TO K-1 1980 H=9E+09 1990 FOR J=0 TO K-1 2000 IF VAL(A$(J))<H THEN H=VAL(A$(J)) : J1=J 2010 NEXT J 2020 X$(L)=A$(J1) : A$(J1)="9E9" 2030 Y$(L)=B$(J1) : B$(J1)="9E9" 2040 Z$(L)=C$(J1) : C$(J1)="9E9" 2050 NEXT L 2060 LPRINT "These numbers were identified: ":LPRINT 2070 LPRINT TAB(10)"CLIENT NUMBER"TAB(30)"AMOUNT TO BILL"TAB(60)"PHONE NUMBER" 2080 LPRINT TAB(10)"-------------"TAB(30)"--------------"TAB(60)"------------" 2090 FOR J=0 TO K-1 2100 LPRINT TAB(10)X$(J);:LPRINT TAB(30);USING FM1$;VAL(Z$(J));:LPRINT TAB(60);USING FM2$;VAL(Y$(J)) 2110 TOT=TOT+VAL(Z$(J)) 2120 NEXT J 2130 LPRINT TAB(30)"--------------" 2140 LPRINT "Total identified =";:LPRINT TAB(30);USING FM1$;TOT:TOT=0 2150 LPRINT STRING$(75,"="):LPRINT "The following phone numbers on the bill had no corresponding client number":LPRINT "on file. Some attempt should be made to find them, and they should be added":LPRINT "to the client number file.":LPRINT 2160 LPRINT TAB(10)"CLIENT NUMBER?"TAB(30)"AMOUNT"TAB(60)"PHONE NUMBER" 2170 LPRINT TAB(10)"--------------"TAB(30)"------"TAB(60)"------------" 2180 OPEN "I",1,"UNKNOWN.DAT" 2190 WHILE NOT EOF(1) 2200 T=1 2210 INPUT #1,F$,G$ 2220 LPRINT TAB(30);USING FM1$;VAL(G$);:LPRINT TAB(60);USING FM2$;VAL(F$) 2230 TOT=TOT+VAL(G$) 2240 WEND 2250 IF TOT=0 THEN 2280 2260 LPRINT TAB(30)"------":LPRINT "Total unidentified =";:LPRINT TAB(30);USING FM1$;TOT 2270 GOTO 2290 2280 LPRINT TAB(10)"There were no unidentified numbers." 2290 LPRINT STRING$(75,"=") 2300 CLOSE 2310 CLEAR 2320 PRINT CHR$(7) : GOTO 20 2330 REM COPYRIGHT (C)1982 STEVEN WHITNEY.
|
|
|
|
|
|