Domino Code Fragment

Code Name*
Phone Number input translation
Date*
02/13/1999
Source (or email address if you prefer)*
Jamie Magee
IP address:.3.144.253.161
Description*
take any US phone number in any format, and change it to (###) ###-#### format
Type*
Formula
Categories*
User Interface (Notes), User Interface (Web)
Implementation:
Modify constants
Required Client:
Server:
Limitations:
Comments:
Use in the Input Translation formula
Files/Graphics attachments (if applicable): Code:
NewPhone := @Trim(@Implode(@Explode(Phone;"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ?!@#$%^&*_+=[]{}|\"<>,.\';:()/\\- ";0);""));
@If(@Length(NewPhone)=11 & (@Left(NewPhone;1)="1" | @Left(NewPhone;1)="0");
            @Return(@Left(NewPhone;1) + " (" + @Middle(NewPhone;1;3) + ")" +
                   @Middle(NewPhone;4;3) + "-" + @Right(NewPhone;4));
       @Length(NewPhone)=10;
            @Return("(" + @Left(NewPhone;3) + ") " + @Middle(NewPhone;3;3) + "-" + @Right(NewPhone;4));
       @Length(NewPhone)=7;
            @Return(@Left(NewPhone;3) + "-" + @Right(NewPhone;4));
       @Do(
                   @Prompt([OK];"Unrecognizable Phone Number";"Unable to interpret Phone Number");
                   @Return(Phone)
                  )
)