"" then
' check for number and mask
dim i, aNumberAndMask, sNumber, sMask
aNumberAndMask = GetNumberAndMask(iInput)
sNumber = aNumberAndMask(0)
sMask = aNumberAndMask(1)
' if they exist, format the number with it
if sNumber <> "" and sMask <> "" then
FormatSiebelPhoneNumber = FormatNumberWithMask(sNumber,sMask)
else ' there's no mask
if len(iInput) = 10 then ' if the number looks like a us number, format it as such
FormatSiebelPhoneNumber = mid(iInput,1,3) & "." & mid(iInput,4,3) & "." & mid(iInput,7,4)
else ' otherwise apply no formatting
FormatSiebelPhoneNumber = iInput
end if
end if
end if
end function
function GetNumberAndMask(iInput)
dim i, bFound, sNumber,sMask
for i=1 to len(iInput)
if not bFound then ' still looking for the divider
if cint(asc(mid(iInput,i,1))) = 10 then ' 10 is the ascii for siebel's mask divider
bFound = true ' we have it
else
sNumber = sNumber & mid(iInput,i,1) ' otherwise add character to the number
end if
else ' once we've passed the divider, put characters in the mask
sMask = sMask & mid(iInput,i,1)
end if
next
GetNumberAndMask = array(sNumber,sMask)
end function
function FormatNumberWithMask(sNumber,sMask)
sNumber = strReverse(sNumber) ' work the number from the back because the mask doesn't apply to country codes
sMask = strReverse(sMask)
dim i, iNumLen, iNumStep, sOutput
iNumLen = len(sNumber)
iNumStep = 1
for i=1 to len(sMask)
if mid(sMask,i,1) = "0" then
sOutput = sOutput & mid(sNumber,iNumStep,1)
iNumStep = iNumStep + 1
elseif mid(sMask,i,1) = " " then
sOutput = sOutput & "."
end if
next
' output difference of characters between iNumStep and iNumLen
if iNumLen - iNumStep > 0 then sOutput = sOutput & "." & right(sNumber,iNumLen - iNumStep + 1)
' put output in right order
FormatNumberWithMask = strReverse(sOutput)
end function
%>