Scripting for the zip code

James Hurley jhurley0305 at sbcglobal.net
Thu Dec 12 20:02:16 EST 2013


Wonderful Scott. And very robust. Not too fussy about leaving out the suffixes, Rd, Ave, Court, etc.

And it runs reasonable quickly for a short sequence of requests.

Thanks, 

Jim



> Message: 11
> Date: Thu, 12 Dec 2013 10:32:06 -0800
> From: Scott Rossi <scott at tactilemedia.com>
> To: LiveCode Mail List <use-livecode at lists.runrev.com>
> Subject: Re: Scripting for the zip code
> Message-ID: <CECF3F59.33C7B%scott at tactilemedia.com>
> Content-Type: text/plain;	charset="US-ASCII"
> 
> Hi Jim:
> 
> You can try the following functions if you're looking up a single US
> address (watch line wrapping).  Pass the street/city/state info to the
> first function as separate arguments.
> 
> function getZip pStreet, pCity, pState
>   put "http://maps.googleapis.com/maps/api/geocode/json?address=" into
> baseURL
>   put "&sensor=false" into URLsuffix
>   --
>   put cleanString(pStreet) into streetData
>   put streetData & comma into theStreet
>   replace space with "+" in theStreet
>   --
>   put cleanString(pCity) into cityData
>   put cityData & comma into theCity
>   replace space with "+" in theCity
>   --
>   put cleanString(pState) into stateData
>   put stateData into theState
>   replace space with "+" in theState
>   --
>   -- GET GEO DATA
>   put baseURL & theStreet & "+" & theCity & "+" & theState & URLsuffix
> into geoURL
>   put url geoURL into theGeoData
>   if "ZERO_RESULTS" is in theGeoData then return "No geocode data found."
>   --
>   -- RETRIEVE ZIP CODE
>   put line lineOffset("formatted_address",theGeoData) of theGeoData into
> temp
>   return word 2 of item -2 of temp
> end getZip
> 
> 
> function cleanString pString
>   replace "." with empty in pString
>   replace "," with empty in pString
>   if char -1 of pString is space then delete char -1 of pString
>   return pString
> end cleanString
> 
> 
> 
> Regards,
> 
> Scott Rossi
> Creative Director
> Tactile Media, UX/UI Design
> 





More information about the use-livecode mailing list