Scripting for the zip code

Scott Rossi scott at tactilemedia.com
Thu Dec 12 13:32:06 EST 2013


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




On 12/12/13 7:53 AM, "James Hurley" <jhurley0305 at sbcglobal.net> wrote:

>Is there a way to *script* for the zip code given
>
>Street address
>City
>State
>
>It used to be possible using the USPS web site, it was even possible to
>get the nine digit zip, but no longer.
>
>But for now, all I need is the 5 digit zip.
>
>Thanks,
>
>Jim Hurley
>_______________________________________________
>use-livecode mailing list
>use-livecode at lists.runrev.com
>Please visit this url to subscribe, unsubscribe and manage your
>subscription preferences:
>http://lists.runrev.com/mailman/listinfo/use-livecode
>






More information about the Use-livecode mailing list