Tip on Coding URLs
Dan Shafer
revdan at danshafer.com
Wed Jul 21 02:26:13 EDT 2004
I can't find the old Tip of the Week (Year?) on the RunRev site. Maybe
they've given it a decent burial.
But this one seemed worth sharing.
Tonight in a late-night coding session I ran into a problem using a URL
argument. Chipp Walters gave me a tip that saved my bacon and will do
so many times over.
If you've ever tried to pass a URL in a variable, at least in OS X,
you've found that it doesn't work. Thus:
put "file:/Users/smith/Documents/Stuff/notes.html" into tURL
put field "Test" into URL tURL
will (at least for me) always break. No error, just no output. So over
the year or so I've been working with URLs, I've come to modify that
two-line script like so:
put "/Users/smith/Documents/Stuff/notes.html" into tURL
put field "Test" into URL "file:" & tURL
For some reason that has generally worked.
Last night I had a more complex situation and no matter what syntax I
tried, I could not get Rev to write the HTML file for me. I pinged
Chipp and he suggested I *always* put URL arguments in parentheses. He
also said that he, too, has had no luck passing a complete URL as a
variable, and generally breaks it into at least two pieces. But putting
them into parentheses makes things work, at least so far, much more
reliably. I would never have thought to do this since URL isn't a
function, but this was a valuable lesson. I hope others can benefit
from Chipp's hard-won wisdom.
put field "Teset" into URL ("file:" & tURL)
and other combinations of more complex URL assembly all seem to work
fine.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dan Shafer, Revolutionary
Author of "Revolution: Software at the Speed of Thought"
http://www.revolutionpros.com for more info
Available at Runtime Revolution Store (http://www.runrev.com/RevPress)
More information about the use-livecode
mailing list