a tip for newbies (like me)

Yates, Glen JAMES.G.YATES at saic.com
Wed Mar 20 15:29:00 EST 2002

Analyzing this had me thrown, until I realized you were missing 1 key piece
of information, your line starting with "put" should really be:

	put url ("file:" & it) into field "myField"

With this you can see that the use of parentheses here is not just a special
case but follows the rules for the parsing of all arguments to containers,
functions, etc.

When you use "put url" it expects a container, so the next item listed is
the container it uses, in the example without parens that would be:

	put url "file:" & it into field "myField"

So in this case the container for put url is only "file:", which since it
probably doesn't point to an actual file returns an empty string, which then
gets concatenated with "it" and put into the field.

When parens are used however:

	put url ("file:" & it) into field "myField"

The parens force the concatenation of "file:" & it to occur before being
evaluated as a container of type "url", so now that container evaluates to a
file that actually exists and its contents get put into the field.

Received more messages in this thread while typing this message:

(from another message)
>Me too!  I believe it will work with both "put" and "put URL".  But the
>parentheses are apparently the key to using variables there.  There is
>probably another way to do it, but that is the only method I know right
>And in response to these messages, no you cannot leave out "url" in this
>construct and expect the contents of the file to be put into your field 

No, you must use "put url" if your objective is to put the contents of the
file into the field. Otherwise you would have to do an "open file" to get at
the file contents.

Also one more point, the "ask file" below should really be:

	answer file "What file?"

As, "ask file" is for saving files, and "answer file" is for
locating/opening them.

-Glen Yates

BCE wrote:
> The RIGHT method: (at least for me, on windows)
> on mouseup
>     ask file "What file?"
>     put ("file:" & it) into field "myField"
> end mouseup
> Notice the parentheses in the second line --- they make the 
> difference.
> Otherwise, just the name of the file is put into the field, 
> and not the
> contents, and a lot of hair pulling occurs.  Apparently if you're
> concantenating a variable and some text into the name of a 
> file, this needs
> to be done.

More information about the use-livecode mailing list