dumb question #1
ambassador at fourthworld.com
Tue Jun 6 15:43:32 CDT 2006
Josh Mellicker wrote:
> I'm going to ask some dumb questions,
As they say, the only dumb question is the one that isn't asked. Even
things that seem rudimentary are probably very valuable to a great many
readers of this list.
I'm glad you raised this one, as it touches on some common issues unique
to this wacky family of languages:
> if i put:
> put URL "file:" & htmPathFile into fld "htm"
> this results in the path & filename going in the field, not the
> contents of the file.
> but this:
> put "file:" & htmPathFile into tFile
> put URL tFile into fld "htm"
> results in the actual text content of that file being put in.
> I don't understand why they are different?!?
It sounds like the engine is doing things in stages that makes sense for
itself, even if it may not be intuitive for humans.
With the first example the engine is doing:
1. get URL "file:"
-- and since there isn't a file at "file:" it returns empty
2. Append htmlPathFile to the result
3. Return the result
And in the second it's doing what you want:
1. Make a full path by concatenating "file:" and the path
2. get that URL
3. return the result
One way to force the order of operations as you want them is to use
put URL ("file:"&htmlPathFile) into tFile
I tend to use parens generously, even in cases where they may not be
absolutely necessary, mostly because I find it makes the logic of the
code more self-evident.
get the width of cd 1+1
...will usually return the width of the card with 1 added to it, rather
than return the width of card 2, since it usually evaluates expressions
from left-to-right (exceptions are noted in the "Order of Precedence"
section of the docs).
Just the same, I find this easier to read when I come across it again 6
months later when I've long forgotten what it was I was doing:
get (the width of cd 1)+1
Managing Editor, revJournal
Rev tips, tutorials and more: http://www.revJournal.com
More information about the use-livecode