REM This program written for the public domain by Ben Jones, Mar-Aug 1994. REM Any comments to BJTranslations@bigfoot.com please! REM REM This version takes into account the price reductions from June 1994. REM REM It has also been updated to include a timer (for use while you are on REM the phone). It would be nice if this could tell automatically if it's REM the weekend or not ... someone send me a simple routine, please? REM REM It does not include rates for mobile phones, premium rate services, etc. REM or for Mercury (as it's not yet available here). If anyone incorporates REM these please send me a copy of the amended version! It does allow you to REM enter things like Option 40 for different unit rates, although BT say the REM whole "unit rate" system may be abolished sometime soon. REM REM Postscript, June 2000: NONE of the figures here are valid any more, but REM you may be able to adapt this to suit your own purposes ... feel free! DECLARE SUB roundup () COMMON duration, rateval, num, cost, unitrate COMMON costnorm, costopt AS LONG DIM ukrates$(3, 5) REM timeband,secs/unit - local,a,b1,b DATA Cheap,220,80.80,37.95,50.35 DATA Standard,80,36.15,25.6,32 DATA W/e cheap,220,90,90,90 countries: DIM bands$(15, 4) REM band,secs/unit - cheap,standard,countries DATA 0,0,0,UK ENGLAND BRITAIN WALES SCOTLAND NORTHERN-IRELAND DATA IR,15,10.48,EIRE IRELAND DATA 1,10,8.34,FRANCE GERMANY SPAIN GIBRALTAR BELGIUM HOLLAND NETHERLANDS DENMARK SWITZERLAND ITALY PORTUGAL DATA 2,7.7,6.53,HUNGARY POLAND NORWAY FINLAND AUSTRIA SWEDEN CZECH DATA 3,5.21,4.4,TUNISIA TURKEY SLOVENIA BULGARIA LIBYA ICELAND YUGOSLAVIA DATA 4,6.35,5.90,USA AMERICA CANADA DATA 5,4.5,3.8,BAHAMAS TRINIDAD JAMAICA ANTIGUA BERMUDA GRENADA DATA 6,5.09,4.35,AUSTRALIA NEW-ZEALAND OZ DATA 7,4.06,3.26,HONG-KONG SINGAPORE DATA 8,3.65,2.93,HAITI SOUTH-AFRICA SAUDI-ARABIA RUSSIA OMAN CUBA GUYANA LATVIA LITHUANIA ESTONIA UKRAINE DATA 8a,3.23,2.61,ISRAEL DATA 9,2.74,2.35,EGYPT JORDAN LEBANON SYRIA BAHRAIN DATA 10,2.68,2.27,ARGENTINA BRAZIL URUGUAY VENEZUELA MALAWI SIERRA-LEONE IRAN IRAQ PERU DATA 11,3.04,2.89,JAPAN DATA 12,2.35,2.23,INDIA PAKISTAN BANGLADESH SRI-LANKA DATA 13,2.3,2.19,VANUATU KOREA CHINA MACAO GUAM MALAYSIA NEPAL THAILAND MEXICO RESTORE FOR x = 1 TO 3: FOR y = 1 TO 5: READ ukrates$(x, y): NEXT: NEXT RESTORE countries FOR x = 0 TO 15: FOR y = 1 TO 4: READ bands$(x, y): NEXT: NEXT CLS PRINT " BT telephone charges calculator" PRINT " ===============================" unitrate = 4.2 REM alter above for Normal (4.2->4.935), Option 40 (3.68->4.324), etc. PRINT "Unit rate"; unitrate; "p + 17.5% VAT ("; unitrate * .175; ") ="; unitrate * 1.175; "p" country$ = "UK" uk = 1 weekend$ = "N": REM should actually be calculated from today's date, but how? PRINT restart: LOCATE , 52: PRINT country$; : LOCATE , 1 INPUT ; "Country (e.g. UK; use hyphens rather than spaces): ", cntry$: IF cntry$ <> "" THEN country$ = cntry$: REM allow CR for default option country$ = UCASE$(country$) IF country$ = "US" THEN country$ = "USA" IF country$ = "IRELAND" THEN country$ = "EIRE": REM otherwise finds "Northern-Ireland"! FOR band = 0 TO 15: site = INSTR(bands$(band, 4), country$): IF site <> 0 THEN GOTO found NEXT band IF band = 16 THEN PRINT "Country not found: try another nearby!": GOTO restart found: temp1 = INSTR(site, bands$(band, 4) + " ", " "): country$ = MID$(bands$(band, 4), site, temp1 - site) LOCATE , 52: PRINT country$; " (band "; bands$(band, 1); ")" IF band = 0 THEN LOCATE , 51: PRINT uk; : LOCATE , 1 INPUT "1) Local, 2) Close (35 miles), 3) Far, 4) London: ", ku: IF ku <> 0 THEN uk = ku END IF LOCATE , 47: PRINT weekend$; : LOCATE , 1 INPUT "Call made at weekend (Fri 23:59 - Sun 23:59)? ", we$: IF LEN(we$) <> 0 THEN weekend$ = UCASE$(we$) tm$ = TIME$ tm = VAL(LEFT$(tm$, 2)) + VAL(RIGHT$(tm$, 2)) / 60 IF band = 0 THEN area$ = MID$("Local Close Far London", uk * 6 - 5, 6) REM cheap Mon-Fri 18-08, all weekend IF weekend$ = "Y" THEN ratenum = 3: GOTO daydone IF tm < 8 OR tm >= 18 THEN ratenum = 1 ELSE ratenum = 2 daydone: rateval = VAL(ukrates$(ratenum, uk + 1)) ELSE IF weekend$ = "Y" OR tm >= 18 OR tm < 8 THEN rateval = VAL(bands$(band, 2)) ELSE rateval = VAL(bands$(band, 3)) END IF END IF LOCATE , 61: PRINT now$; : LOCATE , 1 INPUT "Are you about to call now (& shall I time it for you)? Y/N: ", won$: IF LEN(won$) <> 0 THEN now$ = won$ now$ = UCASE$(now$) tm$ = TIME$ IF now$ = "N" THEN INPUT ; "Duration Minutes: ", min LOCATE , 26: INPUT "Seconds: ", sec duration = min * 60 + sec IF weekend$ <> "Y" THEN REM Time is irrelevant at weekends LOCATE , 29: PRINT tm$; : LOCATE , 1 INPUT "Time (24-hour, e.g. 08:55): ", mt$: IF LEN(mt$) <> 0 THEN tm$ = mt$ END IF ELSE PRINT "Press a key once you are connected"; DO: LOOP UNTIL INKEY$ <> "" start = TIMER: start$ = TIME$ LOCATE , 1: PRINT "Press a key when you hang up "; DO LOCATE , 34: PRINT INT(TIMER - start); " secs"; LOCATE , 54: PRINT INT((TIMER - start) / rateval + 1) * unitrate; " pence"; LOOP UNTIL INKEY$ <> "" duration = TIMER - start: PRINT END IF IF band = 0 THEN PRINT area$; " area"; ELSE PRINT country$; END IF PRINT " at "; IF weekend$ = "Y" THEN tm$ = "weekend" PRINT tm$; " for"; duration; "seconds"; IF band = 0 THEN PRINT " ("; ukrates$(ratenum, 1); " rate to charge band "; MID$("L a b b1", uk * 2 - 1, 2); ")" ELSE PRINT END IF REM print accurate cost (duration/rateval * unitrate) CALL roundup LOCATE , 21: PRINT "Y"; : LOCATE , 1 INPUT ; "Check more figures? ", yesno$ IF UCASE$(yesno$) = "Y" OR LEN(yesno$) = 0 THEN LOCATE , 1: PRINT " ": GOTO restart SYSTEM END SUB roundup SHARED duration, rateval, num, cost, unitrate IF INT(duration / rateval) <> (duration / rateval) THEN num = INT(duration / rateval) + 1 ELSE num = INT(duration / rateval) END IF costnorm = num * 4.2 costopt = num * unitrate IF costopt < 100 THEN PRINT "*** Normal cost of call:"; costnorm; "+ VAT ("; costnorm * .175; ") ="; CLNG(costnorm * 117.5) / 100; "p ***" IF unitrate <> 4.2 THEN PRINT "*** Actual cost:"; costopt; "+ VAT ("; costopt * .175; ") ="; CLNG(costopt * 117.5) / 100; "p ***" ELSE costnorm = costnorm / 100 costopt = costopt / 100 PRINT "*** Normal cost of call: "; costnorm; "+ VAT ("; costnorm * .175; ") ="; CHR$(156); CLNG(costnorm * 117.5) / 100; " ***" IF unitrate <> 4.2 THEN PRINT "*** Actual cost:"; costopt; "+ VAT ("; costopt * .175; ") ="; CHR$(156); CLNG(costopt * 117.5) / 100; " ***" END IF END SUB