Nine digit zip codes.

Jim Ault jimaultwins at yahoo.com
Sat Nov 27 23:30:51 EST 2010


The 'submit' button on a page will do one of two things.  Either
   send a GET string
   send a POST message
The USPS page uses    "

The GET is a simple method of send a web page address & the data pairs.
- this method has a limit of about 1000 chars and is sent so that a  
program sniffing packets can see the entire string

The POST is a more capable method that sends the web page address &  
another message that can contain a variety of encoded data.
- this method does not have a limit and the variables cannot be sniffed

In your case, the LC 'post' command is the 'submit' button action.
In the LC library, the web page address and the message are formatted  
for you

Think of the receiving web page as a hander in LC.
The post message calls the handler and passes the variables defined by
      pVar1=string&pVar2=integer&pVar3=state&pVar4=city

Now the server program gets called, crunches, and returns what it is  
programmed to return, just like a LC handler or function.

The POST command can also send images (as binary endoded as a text  
block), sounds, videos, files, etc.
The key is to format the message so that the sever program can know  
how to decode the text and where the parts begin and end, if multiple  
parts are sent in one message.  This is the function of 'multi-part  
boundaries' (long random strings that divide the parts)

On Nov 27, 2010, at 3:46 PM, James Hurley wrote:

> Richard,
>
> I'm beginning to get it. I should put
>
>>> visited
>>> =1&pagenumber=0&firmname=&address2=620+moulton&address1=&city=los 
>>> + 
>>> angeles 
>>> &state=ca&urbanization=&zip5=90031&submit.x=48&submit.y=8&submit=Fin
>
>
>
> into field 1--or, of course, the data appropriate to my addresses.
>
> But where did this "visited" line come from? Where in the process of  
> sending the "submit" does this line present itself?
>
> Jim
>
>
>
>> Richard,
>>
>> Thanks. I am astonished that this is possible.
>>
>> I'm afraid I am missing something. I tried entering my data (my  
>> home address--it appears that is what you did) in the USPS page
>>> http://zip4.usps.com/zip4/
>>
>> I then copied and pasted that source code into field 1 in LiveCode.  
>> (I didn't see any reference to my data--my address--in that html  
>> text.)
>>
>> I used your script in a button and obtained some html text in field  
>> 2. But there is no reference in field 2 to my street address.
>>
>> I don't mind working on the parsing to do the put and get, but I'm  
>> sure I missing the ingredient where my data (address, city and St)  
>> goes into field 1. I think that is what I am missing.
>>
>> I don't see "visited=1&pagenumber=0 etc. anywhere in field 1 or 2.
>>
>> Floundering,
>>
>> Jim
>>
>>
>>
>>
>>
>>
>>>
>>> James Hurley wrote:
>>> > At the USPS web site (http://zip4.usps.com/zip4/) it is possible  
>>> by
>>> > entering the street address, the city and the state to obtain  
>>> the 9
>>> > digit zip code for that address.
>>> >
>>> > This may be naive, but is it possible to do this from within  
>>> LiveCode
>>> > by script?
>>> Good news:  you can use the post command for that.
>>> Bad news:  the result is HTML, so you'll need to parse out the  
>>> relevant
>>> parts.
>>>
>>> To test I made a stack with a button and two fields - here's the  
>>> script
>>> for the button, using the URL derived from the HTML source of the  
>>> form
>>> element in that page:
>>>
>>> on mouseUp
>>>  post fld 1 to url "http://zip4.usps.com/zip4/zcl_0_results.jsp"
>>>  set the htmlText of fld 2 to it
>>> end mouseUp
>>>
>>> Field 1 contains form element names and values, packaged up in the
>>>
>>> name=value format used by both POST and GET:
>>>
>>> visited 
>>> =1&pagenumber=0&firmname=&address2=620+moulton&address1=&city=los 
>>> + 
>>> angeles 
>>> &state=ca&urbanization=&zip5=90031&submit.x=48&submit.y=8&submit=Fin
>>>
>>> Field 2 will contain the HTML once the request is returned.  Now  
>>> for the
>>> tedious parsing to get the parts you want....
>>> -- 
>>> Richard Gaskin
>>> Fourth World
>>> LiveCode training and consulting: http://www.fourthworld.com
>>> Webzine for LiveCode developers: http://www.LiveCodeJournal.com
>>> LiveCode Journal blog: http://LiveCodejournal.com/blog.irv
>>>
>>
>
> _______________________________________________
> 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

Jim Ault
Las Vegas






More information about the use-livecode mailing list