Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
PostOffice Intelligent Barcodes
Message
De
09/03/2017 13:12:25
 
 
À
08/03/2017 09:22:21
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows 10
Divers
Thread ID:
01648854
Message ID:
01648878
Vues:
79
This is from a very old VFP 6 app, and I have never been through the code, but it does work and is in production:
*************************************************************************
*************************************************************************
*!* |--------------------------------------------------------------------
*!* | FUNCTION PostNet
*!* |--------------------------------------------------------------------
*!* |	Creates character string to be encoded by PostNet font.
*!* |	Attempts to extract house # first from tcAddr2 and if not found,
*!* |	    then from tcAddr1
*!* |	Adds CheckSum digit.
*!* |  	PostNet("11375-0102","Parker Towers","104-70 Queens Boulevard") =>
*!* |	                   "<113750102703>"
*!* |  	PostNet("11375-0102","104-70 Queens Boulevard") => "<113750102703>"
*!* |--------------------------------------------------------------------
*!* |	Parameter  Meaning
*!* |	---------  --------------------------------------------------------
*!* |	tcZip      5 or 9 character Zip Code - must contain only digits and "-"
*!* |	tcAddr1    first line of address, used for finding house #
*!* |	tcAddr2    second line of address, used for finding house #
*!* |--------------------------------------------------------------------
	FUNCTION PostNet
	PARAMETERS tcZip,tcAddr1,tcAddr2
	jcHouseNum=""
	tcAddr2=IIF(PARAMETERS()<3,"",tcAddr2)
	tcAddr1=STRTRAN(tcAddr1,"-")
	tcAddr2=STRTRAN(tcAddr2,"-")
	IF !EMPTY(tcAddr2)
		FOR jnFirstDig=1 TO LEN(ALLTRIM(tcAddr2))
			IF ISDIGIT(SUBSTR(ALLTRIM(tcAddr2),jnFirstDig))
				EXIT
			ENDIF
		ENDFOR
		IF ISDIGIT(SUBSTR(ALLTRIM(tcAddr2),jnFirstDig))
			FOR jnLastDig=jnFirstDig TO LEN(ALLTRIM(tcAddr2))
				IF !ISDIGIT(SUBSTR(ALLTRIM(tcAddr2),jnLastDig))
					EXIT
				ENDIF
			ENDFOR
			jnLastDig=IIF(!ISDIGIT(SUBSTR(ALLTRIM(tcAddr2),jnLastDig)),jnLastDig-1,jnLastDig)
			jcHouseNum=IIF(jnFirstDig=jnLastDig,"0"+SUBSTR(tcAddr2,jnLastDig,1),;
			SUBSTR(tcAddr2,jnLastDig-1,2))
		ENDIF
	ENDIF
	IF EMPTY(jcHouseNum) AND !EMPTY(tcAddr1)
		FOR jnFirstDig=1 TO LEN(ALLTRIM(tcAddr1))
			IF ISDIGIT(SUBSTR(ALLTRIM(tcAddr1),jnFirstDig))
				EXIT
			ENDIF
		ENDFOR
		IF ISDIGIT(SUBSTR(ALLTRIM(tcAddr1),jnFirstDig))
			FOR jnLastDig=jnFirstDig TO LEN(ALLTRIM(tcAddr1))
				IF !ISDIGIT(SUBSTR(ALLTRIM(tcAddr1),jnLastDig))
					EXIT
				ENDIF
			ENDFOR
			jnLastDig=IIF(!ISDIGIT(SUBSTR(ALLTRIM(tcAddr1),jnLastDig)),jnLastDig-1,jnLastDig)
			jcHouseNum=IIF(jnFirstDig=jnLastDig,"0"+SUBSTR(tcAddr1,jnLastDig,1),;
			SUBSTR(tcAddr1,jnLastDig-1,2))
		ENDIF
	ENDIF
	jcZip=STRTRAN(ALLTRIM(tcZip),"-")
	IF !INLIST(LEN(jcZip),5,9)
		RETURN ""
	ENDIF
	FOR i=1 TO LEN(jcZip)
		IF !ISDIGIT(SUBSTR(jcZip,i))
			RETURN ""
		ENDIF
	ENDFOR
	jcZip=IIF(LEN(jcZip)=5,jcZip,jcZip+ALLTRIM(jcHouseNum))
	jnSumDigits=0
	FOR i=1 TO LEN(jcZip)
		jnSumDigits=jnSumDigits+VAL(SUBSTR(jcZip,i,1))
	ENDFOR
	jcCheckDig=ALLTRIM(STR(IIF(MOD(jnSumDigits,10)=0,0,10-MOD(jnSumDigits,10))))
	jcZip="<"+jcZip+jcCheckDig+">"
	RETURN jcZip
>Hello--
>
>Has anyone worked with the USPS Intelligent Barcodes with VFP? I am now needing to add this support and looking at options and ways to incorporate this functionality. Any advice or sample code would be greatly appreciated.
>
>Greg
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform