REM "**** Define Standard Variables ***";
REM;
@If(Phone="";@Return("");"");
Phone0 := @ReplaceSubstring (Phone; "("; "");
Phone2 := @ReplaceSubstring (Phone0; ")"; "");
Phone3 := @ReplaceSubstring (Phone2; "-"; "");
Phone4 := @ReplaceSubstring (Phone3; "/"; "");
Phone5 := @ReplaceSubstring (Phone4; " "; "");
Phone6 := @ReplaceSubstring (Phone5; "_"; "");
Phone7 := @ReplaceSubstring (Phone6; "="; "");
LengthPhone := @Length (Phone7);
Phone8:= @If(LengthPhone > 10 ; @Right (Phone7; 10); Phone7);
nofrillphone := @Trim(Phone8);
REM "Set default area code if none intered to 714";
area := @If(LengthPhone = 7;"714";@Left(nofrillphone;3));
other := @If(LengthPhone = 7;nofrillphone;@Right(nofrillphone; area));
pre := @Left(other; 3);
suffix := @Right(other;4);
PhoneLen := (LengthPhone -10);
dialPre := @If(LengthPhone > 10; @Left(Phone7;PhoneLen); "");
@If(LengthPhone>10; Phone; DialPre + "(" + area + ") " + pre + "-" + suffix)
This was first published in November 2000