! ********************* USPS ************************* ! Program to create a Intelligent Mail Bar Code ! Applied Micro Systems, Hungtingdon Valley, PA ! Joe Leibel - 01/Jan/11 ! [1] Jack McGregor - 10/Nov/11 (added notes about using ! XCALL USPSBS) !******************************************************* STRSIZ 100 MAP1 AUTO'MAPPED'VARS MAP2 ZIP'CODE$,S,100 MAP2 STREET'NO$,S,100 MAP2 STREET'NAME$,S,100 MAP2 STATE$,S,100 MAP2 SP,F,6 MAP2 NAME$,S,100 MAP2 CITY$,S,100 MAP2 COL,F,6 MAP2 CENTER'ROW,F,6 MAP2 USPS$,S,100 MAP2 TOP'ROW,F,6 MAP2 BEG'COL,F,6 MAP2 BOT'ROW,F,6 MAP2 D$,S,100 MAP2 ROW,F,6 ! ! The contents of the Delivery Point Bar Code is Zip+4 ! plus the last 2 digits of the street number plus a check digit ! ! ******* Set up the Test Variables ******* ZIP'CODE$ = "190061610" ! zip+4 zip code (Required) STREET'NO$ = "400" ! Street Number (Required) NAME$ = "Mr. Joe Leibel" STREET'NAME$ = "Pike Rd" CITY$ = "Huntingdon Valley" STATE$ = "PA" ![1] This is a hard-coded example... USPS$ = "AADTFFDFTDADTAADAATFDTDAAAADDTDTTDAFADADDDTFFFDDTT" ![1] In the real world, you would generate the code string using: ! XCALL USPSBS, TRACKSTR, ROUTESTR, USPS$, STATUS !(see release notes for edit 5.1.1201 and USPS docs for info on the ! TRACKSTR and ROUTESTR params; also see USPSTST.BP program) ! ******* Output to the File ****** ! OPEN # 1,"USPS.TXT",OUTPUT ?#1,"//SETMAPMODE,HIENGLISH" ! 1000th of an Inch ?#1,"//SETPENEX,256,20" ! Solid, 20 / 1000th thick bars ?#1,"//SETFONT,100,COURIER NEW,0,0,700,0" ! ******** Print the Name & Address ******* ! TOP'ROW = 4000 ! Starting Row 4 inches (4000/1000) down BEG'COL = 1000 ! Starting Column 1 inch (1000/1000) in COL = BEG'COL CENTER'ROW = TOP'ROW + 80 ! Center point of Bar Codes ! *** Bar Code width - .02 inches +/- .005 ! *** Full Bar Height - .145 inches +/- .02 or .125 to .165 total ! *** Ascender Height - .073 Up & .025 Down | .082 to .111 total ! *** Tracker Height - .025 Up & .025 Down | .039 to .057 total ! *** Descender Height - .025 Up & .073 Down | .082 to .111 total ! ********** Print the USPS Bar Code ************ FOR SP = 1 TO LEN(USPS$) D$ = USPS$[SP;1] ! Get one byte 1 or 0 COL = BEG'COL + (SP * 45) ! 22 bars per inch +/- 2 bars ROW = CENTER'ROW IF D$ = "F" THEN TOP'ROW = ROW - 73 : BOT'ROW = ROW + 73 IF D$ = "A" THEN TOP'ROW = ROW - 73 : BOT'ROW = ROW + 25 IF D$ = "T" THEN TOP'ROW = ROW - 25 : BOT'ROW = ROW + 25 IF D$ = "D" THEN TOP'ROW = ROW - 25 : BOT'ROW = ROW + 73 ?#1,"//MOVETO,";STR$(COL);",";STR$(TOP'ROW) ?#1,"//LINETO,";STR$(COL);",";STR$(BOT'ROW) NEXT SP ! Clear Zone must be .125 inches from any other printing ROW = TOP'ROW + 125 + 100 COL = BEG'COL ?#1,"//MOVETO,";STR$(COL);",";STR$(ROW) ?#1,NAME$ ROW = ROW + 200 ?#1,"//MOVETO,";STR$(COL);",";STR$(ROW) ?#1,STREET'NO$;" ";STREET'NAME$ ROW = ROW + 200 ?#1,"//MOVETO,";STR$(COL);",";STR$(ROW) ?#1,CITY$;", ";STATE$;" ";ZIP'CODE$[1;5]; IF ZIP'CODE$[6;4] <> "" THEN ?#1,"-";ZIP'CODE$[6;4]; ?#1 CLOSE # 1 XCALL SPOOL,"USPS.TXT","PRINT1",524288