<<
I seem to remember something in a demo of a
slick way to format a mailing address.
>>


Save the following code as a file named FormatAddress.PRC.  Then issue 

PUT FormatAddress.PRC AS FormatAddress pFA_Company TEXT(30), pFA_Street 
TEXT(30), pFA_Apartment TEXT(30), pFA_City TEXT(20), pFA_State TEXT(2), pFA_Zip 
TEXT(5), pFA_Zip4 TEXT(4) RETURN NOTE

from the R> prompt.

Finally, in your report create a variable rAddress = (CALL 
FormatAddress(Company, Addr1, Addr2, City, State, ZipCode, Zip4)) and you will 
have a note variable, no black lines ready for printing.

Alternatively, base your report on a view and include the formatted address as 
an extra column in the view definition.

Use (CALL FormatAddress()) whereever you need to display a formatted address -- 
forms, reports, labels, views, r> prompt. whatever.

Modify as necessary for your situation (no ZIP4, extra address lines, 
international formatting, etc).

--------------------------------------------------------------
-- FormatAddress: Takes address fields and returns formatted Address
--------------------------------------------------------------
-- PUT FormatAddress.PRC AS FormatAddress pFA_Company TEXT(30), pFA_Street 
TEXT(30), pFA_Apartment TEXT(30), pFA_City TEXT(20), pFA_State TEXT(2), pFA_Zip 
TEXT(5), pFA_Zip4 TEXT(4) RETURN NOTE

IF pFA_Company IS NULL THEN
  RETURN NULL
ENDIF

SET VAR pFA_Result NOTE = (.pFA_Company)
IF pFA_Street IS NOT NULL THEN
  SET VAR pFA_Result = (.pFA_Result + CHAR(13) + CHAR(10) + .pFA_Street)
ENDIF
IF pFA_Apartment IS NOT NULL THEN
  SET VAR pFA_Result = (.pFA_Result + CHAR(13) + CHAR(10) + .pFA_Apartment)
ENDIF

IF pFA_State IS NULL THEN
  SET VAR pFA_Result = (.pFA_Result + CHAR(13) + CHAR(10) + .pFA_City & 
.pFA_Zip + IFNULL(.pFA_Zip4, (CHAR(160)), ("-" + .pFA_Zip4)))
ELSE
  SET VAR pFA_Result = (.pFA_Result + CHAR(13) + CHAR(10) + .pFA_City + "," & 
.pFA_State & .pFA_Zip + IFNULL(.pFA_Zip4, (CHAR(160)), ("-" + .pFA_Zip4)))
ENDIF

RETURN .pFA_Result

--
Larry

Reply via email to