Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search

[REBOL] zip-lookup function

From: doug::vos::eds::com at: 26-Feb-2001 9:03

I wrote a zip lookup function over the weekend. You provide the zip-code and it returns the "city, state". Only works for USA addresses at this time... However, may be of interest to all since it demonstrates a simple way to grab and re-use information from a web-site. (In this case ) What I need... 1. Try this out and tell me about any bugs, and also suggest any improvements. 2. Need the latest version of an "http-post" to improve this function, by working with a "post" to (no pun intended) Try it out and somebody send me the latest and greatest version of http-post also. REBOL [ Title: "Get city and state from zip-code lookup." Date: 24-Feb-2001 File: %zip-looky.r Author: "Doug Vos" Email: [doug--vvn--net] Purpose: "Allow simple data entry with zip code lookups." ] zip-lookup: func [ {Return a [city state zip] block from a zip.} zip [string! integer!] {A zip code like 56789 or 99999-9999.} /local data xblock i cs city state cs-parts ][ data: load/markup copy/part (read rejoin [ zip ]) 4800 xblock: make block! 100 foreach i data [ if string? i [ if not empty? (trim/lines i) [ append xblock i ] ] ] cs: select xblock "Yahoo! Maps" cs-parts: parse/all cs ";" city: first parse/all (first cs-parts) "," state: first parse/all (second cs-parts) "&" reduce [city state] ] probe zip-lookup "01001" probe zip-lookup "02138" probe zip-lookup 10012