Phone - Display and store UK telephone numbers ============================================== File: Phone - Update: 1.10 Author: J.G.Harston - Date: 20-Aug-2009 The Phone library provides functions to display, store and retrive UK telephone numbers. It is an update from the previous library that was only able to cope with 01 and 02 geographic ranges. With the introduction by Ofcom of the 03 geographic range, this library has been updated to cope with the full UK telephone number range. The old Phone library is now renamed to PhoneG for old geographic numbers only. Introduction ============ The previous library handled telephone numbers internally as 4-byte integers. This is insufficient to hold the whole 10-digit UK telephone number range ('0' followed by 10 digits) of 10 billion numbers - a 4-byte integer can only hold a 9-digit number. This library handles telephone numbers internally as 5-byte floats. The 01 and 02 number ranges are still handled as 4-byte integers, so the updated library can be used with existing code that only deals with 01 and 02 numbers without any changes. The previous Phone library strongly implied that the values used to represent telephone numbers were opaque values that shouldn't be interpreted outside the Phone functions. This becomes explicit. The function FNPhone_FromStr() will return a floating point value that has no externally useful connection to the telephone number is represents. The updated library uses the '|' and 'END' functions, so will only run on BASIC V or equivalent. Requirements and Dependancies ============================= BASIC V or equivalent with the '|' and 'END' functions. Pre-BASIC V will only handle 01 and 02 number ranges. Convert telephone number string to value ======================================== DEFFNPhone_FromStr(phone$) Converts the supplied telephone number into a five-byte representation. Any non-digit characters are ignored. 01 and 02 number ranges return a four-byte value. Convert value to telephone number string ======================================== DEFFNPhone_ToStr(number) Converts the passed representation of a UK telephone number into a fixed- length 11-character telephone number string. The only valid values to pass are those previously returned from FNPhone_FromStr(). Convert value to formatted telephone number string ================================================== DEFFNPhone_ToStrF(number) Converts the passed representation of a UK telephone number into a correctly-formatted fixed-length 13-character telephone number string. The only valid values to pass are those previously returned from FNPhone_FromStr(). Examples ======== DIM num(9) FOR n%=0 TO 9 INPUT "Phone number: "A$ num(n%)=FNPhone_FromStr(A$) NEXT FOR n%=0 TO 9 PRINT ;n;": ";FNPhone_ToStrF(num(n%)) NEXT REM Display phone number formatting for number ranges FOR A=10 TO 99 PRINT FNPhone_ToStrF(FNPhone_FromStr("0"+STR$A+"00000000")) IF A<20:PRINT FNPhone_ToStrF(FNPhone_FromStr("0"+STR$A+"10000000")) NEXT Notes ===== Behaviour is undefined for numbers outside the UK number range of 01 to 09 and for numbers passed to Phone_FromStr() without an area code prefix. 00 is the UK dialing prefix for international dialing and such numbers are outside the scope of a UK telephone number handling scheme. The four-byte and five-byte values used to represent telephone numbers are opaque values that only have meaning when passed to and from Phone functions and cannot be manipulated outside Phone functions to give any meaningful results. Version History =============== 1.00 23-Apr-1995 First version written. 1.10 20-Aug-2009 Updated to handle whole UK telephone number range.