Date: Thu, 28 Mar 2024 16:58:54 -0700 (PDT) Message-ID: <266047399.357.1711670334759@wiki.srpcs.com> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_356_1311551113.1711670334759" ------=_Part_356_1311551113.1711670334759 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
ZIP_FORMAT converts entere=
d numbers into a valid US 5-digit or 9-digit zip code, or a valid Canadian =
Postal Code format. This can be extended to include other country cod=
es. The code is included in OpenInsight, with the source in the SYSPROCS table in the
COMPILE SUBROUTINE= ZIP_FORMAT(CHARSTR CONV, CHARSTR ANS, CHARSTR BRANCH, CHARSTR RETURN_DATA) * * ZIP_FORMAT is an example of a developer's custom prompt forma= tting * routine using the square brackets call. * * It should be placed in square brackets, like this: * * &= nbsp; [ZIP_FORMAT] * * This subroutine properly formats any reasonable string of numbers and cha= racters * into a consistent US Zip or Canadian Postal Code format. * * Subroutine declarations DECLARE FUNCTION MSG * Local Equates * The STATUS() variable is used to indicated the error condition of t= he * pattern. They are: EQU VALID$ TO 0  = ; ;* Successful EQU INVALID_MSG$ TO 1 ;* Bad Data  = ; - Print error message window EQU INVALID_CONV$ TO 2 ;* Bad Conversion - &n= bsp; " &nb= sp; " EQU INVALID_NOMSG$ TO 3 ;* Bad but do not print the error= message window * Begin Conversion * BEGIN CONDITION PRE: POST: END CONDITION RETURN_DATA =3D "" IF ANS NE "" THEN ZIP =3D ANS ANS =3D "" STATUS() =3D VALID$ CONVERT " -" TO "" IN ZIP LENGTH =3D LEN( ZIP ) * A case statement is used to validate all possible= types of Postal Codes. * If a new format is required, simply add another c= ase. * The fall-through (CASE 1) traps invalid conversio= ns. BEGIN CASE CASE LENGTH =3D 5 AND NUM( ZIP ) * standard five digit US zi= p code. RETURN_DATA =3D ZIP CASE LENGTH =3D 9 AND NUM( ZIP ) * standard nine digit US zi= p code. IF CONV =3D "OCONV" THEN RETURN_DATA =3D= FMT( ZIP, "L#####-####" ) END ELSE RETURN_DATA =3D= ZIP END CASE LENGTH =3D 6 AND ZIP MATCHES= "1A1N1A1N1A1N" * Canadian-style Postal Cod= e. IF CONV =3D "OCONV" THEN RETURN_DATA =3D= FMT( ZIP, "L### ###" ) END ELSE RETURN_DATA =3D= ZIP END CASE 1 * No pattern matches met. &= nbsp;If called from an input pattern, display * error message. IF CONV =3D "ICONV" THEN RES= P =3D MSG( '', ZIP:" is not a valid Zip code. Please enter a five or nine d= igit number in any format, or a Canadian-style Postal Code." ) END STATUS() =3D INVALID_NOMSG$ END CASE END RETURN * * Source Date: 17:02:51 23 APR 1993 Build ID: OI*1.0.144 = Level: 2.0