Set the Behavior Not Working
Roger Guay
irog at mac.com
Mon Aug 31 21:59:25 EDT 2015
Thanks for taking so much time on this, Richard. I get it now, but here is another example where the dictionary could do better!
> On Aug 31, 2015, at 4:37 PM, Richard Gaskin <ambassador at fourthworld.com> wrote:
>
> An object reference can be a string, or an expression that evaluates to a string. For example these put the same string into the variable tVar:
>
> put the long id of btn id 1721 of stack "SomeStack" into tVar
> put "btn id 1721 of stack ""e& "SomeStack" "e into tVar
>
> The difference between that second expression and the example you gave above that didn't work is that when using the "set" command the tokens following it will be evaluated.
>
> When quoted, or prepended with "the long id of ", the result of that expression is a string, which is then used by the "set" command.
>
> But without quotes the expression is evaluated, which results in "set" using the contents of the button.
>
> This ambiguity in xTalk was handy in allowing us to do things like this:
>
> put fld 1 + fld 2 into fld 3
>
> ...but comes at a cost to ambiguity, since you're not the first person I've come across who expects an object reference to be treated as an object reference rather than as a series of tokens to be evaluated.
>
> Lately I tend to prefer property-driven syntax for its clarity:
>
> set the text of fld 3 to the text of fld 1 + the text of fld 2
>
> Much more cumbersome to write, but avoids the whole question of whether I'm referring to a property of the object or the object itself.
>
> This "explanation" may only add to the confusion, but there's the rub: for all the seeming simplicity of xTalk, there are more than a few such ambiguities, which can make it harder to learn. And I believe this one is among the ambiguities LiveCode Builder addresses.
More information about the use-livecode
mailing list