home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DP Tool Club 13
/
CD_ASCQ_13_0494.iso
/
maj
/
419
/
phone.bas
< prev
next >
Wrap
BASIC Source File
|
1994-03-13
|
2KB
|
62 lines
' +----------------------------------------------------------------------+
' | |
' | PBClone Copyright (c) 1990-1994 Thomas G. Hanlin III |
' | |
' +----------------------------------------------------------------------+
FUNCTION Phone2Num& (PhoneNumber$)
FOR tmp% = 1 TO LEN(PhoneNumber$)
ch$ = UCASE$(MID$(PhoneNumber$, tmp%, 1))
IF ch$ >= "A" AND ch$ <= "Z" THEN
foo% = INSTR("ABCDEFGHIJKLMNOPRSTUVWXY", ch$)
IF foo% THEN
ch$ = MID$("222333444555666777888999", foo%, 1)
ELSE
ch$ = "bogus"
END IF
END IF
IF ch$ >= "0" AND ch$ <= "9" THEN foo$ = foo$ + ch$
NEXT
IF LEN(foo$) = 11 AND LEFT$(foo$, 1) = "1" THEN foo$ = MID$(foo$, 2)
IF LEN(foo$) = 4 OR LEN(foo$) = 7 OR LEN(foo$) = 10 THEN
foo$ = RIGHT$(STRING$(10, "0") + foo$, 10)
IF MID$(foo$, 2, 1) = "1" THEN
Negate% = -1
ELSEIF MID$(foo$, 2, 1) = "0" THEN
Negate% = 1
ELSE
Wrong% = -1
END IF
PhoneNr& = CLNG(VAL(LEFT$(foo$, 1) + MID$(foo$, 3)))
ELSE
Wrong% = -1
END IF
IF Wrong% THEN
Phone2Num& = -1&
ELSE
Phone2Num& = Negate% * PhoneNr&
END IF
END FUNCTION
FUNCTION Num2Phone$ (Number&)
IF Number& = -1& THEN
Num2Phone$ = ""
EXIT FUNCTION
ELSEIF Number& < 0& THEN
Nr& = -Number&
Midget$ = "1"
ELSE
Nr& = Number&
Midget$ = "0"
END IF
foo$ = RIGHT$(STRING$(9, "0") + LTRIM$(STR$(Nr&)), 9)
foo$ = LEFT$(foo$, 1) + Midget$ + MID$(foo$, 2)
IF LEFT$(foo$, 6) = "000000" THEN
Num2Phone$ = RIGHT$(foo$, 4)
ELSEIF LEFT$(foo$, 3) = "000" THEN
Num2Phone$ = RIGHT$(foo$, 7)
ELSE
Num2Phone$ = foo$
END IF
END FUNCTION