Hi -
I had hoped that when I got the "number" issue resolved, I would be able to handle the rest of the programming. Unfortunatley, I am still missing something.
I am simply trying to convert any phone number to a standard format of:
(###) ###-####
which might have been entered in any of several formats, such as:
Tel:(###) ###-#### ###-###-#### ###.###.####
etc.
I was trying to do this with a sub-routine (since I have 5 phone fields that would be affected). I thought the following would work; however, it does nothing. Admittedly, I am "weak" in the area of sub-routines. (The first subroutine has to do with dialing phone numbers and that works just fine).
[code]var vPhonenumber as String Subroutine DialPhone ( ) var VSuccess as Int var vAreacode as string = "813" var vName as String = Mail Name var vPath as String = "C:\sesame\utilities\" vPhonenumber = @num (vPhonenumber) If @len (vPhonenumber) = 10 then { If @left (vPhonenumber, 3) = vAreacode then { vPhonenumber = @Right (vPhonenumber, 7) } Else If @left (vPhonenumber, 3) = "727" then { vPhonenumber = (vPhonenumber) } Else { vphonenumber = 1 + vPhonenumber } }
vsuccess = @Shell(@Chr(34) + vPath + "dial.exe" + @Chr(34) + " " + vPhonenumber + " [" + vName +"]") If not vSuccess = 0 then { @msgbox ("Problem!!! Dialer did not work.", "", "") } end subroutine
Subroutine formatphonenumber ( )
vPhonenumber = @num(vPhonenumber)
if @len(vPhonenumber)=10 then
vPhonenumber = "(" + @Left(vPhonenumber, 3) + ") " + @Mid(vPhonenumber, 4, 3) + "-" + @Right(vPhonenumber, 4) end subroutine [/code]
If I use the "parsing" code in a particular phone field (Home, Work, Cell, Other1 or Other2) it works just fine, but I didn't want to repeat the programming in each field.
The above code is entered in the "Global Code" and in each phone field (on element entry) I have the following:
[code]vPhonenumber = ThisElement[/code]
Also in each phone field (on element exit) I have the following:
[code]formatphonenumber ( )[/code]
Where am I going wrong, please?
|