LiveCode & google maps...
James Hurley
jhurley0305 at sbcglobal.net
Tue Feb 15 16:27:32 EST 2011
Peter,
Thanks. Very interesting.
A couple of questions.
Is "lineoffsets" a custom function or a typo?
And what is the "sr" function?
Thanks again,
Jim Hurley
On Feb 15, 2011, at 10:00 AM, use-livecode-request at lists.runrev.com wrote:
> function getMileage
> put "http://maps.googleapis.com/maps/api/directions/xml?" & \
> "origin=<tOrig>&destination=<tDest>&sensor=false" into tURL
> put fld "from" into tStart
> put fld "to" into tEnd
> replace "<tOrig>" with urlEncode(tStart) in tURL
> replace "<tDest>" with urlEncode(tEnd) in tURL
> put URL tURL into t
> put lineoffsets("<distance>",t) into startSect
> put item -1 of startSect into startSect
> put lineoffsets("</distance>",t) into endSect
> put item -1 of endSect into endSect
> if startSect = 0 or endSect = 0 then
> beep
> exit to top
> end if
> put line startSect+1 to endSect-1 of t into tSect
> put lineoffset("<text>",tSect) into dLine
> if dLine = 0 then
> beep
> exit to top
> end if
> put sr(line startSect + dLine of t) into tMiles
> -- <text>3.6 mi</text>
> replace "<text>" with empty in tMiles
> delete word -1 of tMiles
> return tMiles
> end getMileage
More information about the use-livecode
mailing list