home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DP Tool Club 19
/
CD_ASCQ_19_010295.iso
/
dos
/
prg
/
bas
/
hanlin3
/
pbc30a
/
fmtphone.bas
< prev
next >
Wrap
BASIC Source File
|
1994-03-13
|
1KB
|
36 lines
' +----------------------------------------------------------------------+
' | |
' | PBClone Copyright (c) 1990-1994 Thomas G. Hanlin III |
' | |
' +----------------------------------------------------------------------+
DECLARE FUNCTION AscM% (St$, BYVAL Posn%)
DECLARE FUNCTION UpcaseI% (BYVAL Ch%)
FUNCTION FormatPhone$ (RawSt$)
'--- toss any characters that aren't alphanumeric, 'n' also Q and Z
st$ = ""
FOR tmp% = 1 TO LEN(RawSt$)
ch% = UpcaseI%(AscM%(RawSt$, tmp%))
IF ch% >= 48 AND ch% <= 57 OR ch% >= 65 AND ch% < 90 AND ch% <> 81 THEN
st$ = st$ + CHR$(ch%)
END IF
NEXT
'--- format the result based on the string length
IF LEN(st$) = 11 AND LEFT$(st$, 1) = "1" THEN
st$ = MID$(st$, 2)
END IF
SELECT CASE LEN(st$)
CASE 4
FormatPhone$ = st$
CASE 7
FormatPhone$ = LEFT$(st$, 3) + "-" + RIGHT$(st$, 4)
CASE 10
FormatPhone$ = "(" + LEFT$(st$, 3) + ") " + MID$(st$, 4, 3) + "-" + RIGHT$(st$, 4)
CASE ELSE
FormatPhone$ = ""
END SELECT
END FUNCTION