Dereferencing control ids

Peter Haworth pete at lcsql.com
Mon Jan 27 18:37:15 EST 2014


Hi Scott and Craig,

The controls are selected by mouse clicks.  I too thought a "do" statement
might fix the problem but no luck.

However, I did take Scott's advice and put the selectedObjects into a
variable and now things work OK.  I can't say for sure whether that was
what fixed the issue since I tried many other variations, some of which
remain in the code. Just glad it's working now.

To expand a bit more on dereferencing, I am still unsure as what works and
what doesn't. For example, I can:

put "topLeft" into tProperty
put the tProperty of field "xyz"

... and all works fine.

This also works fine:

put "cPropSet[cProperty]" into tProperty
put the tProperty of field "xyz"

However, If I try this:

put "cPropset" into tPropset
put "cProperty" into tProperty
put the (tPropset & "[" & tProperty & "]") of field "xyz"

... I get a compilation error "bad factor".

To add confusion, if I do this:

put the ("cPropset" & "[" & "cProperty" & "]") of field "xyz"

... it compiles OK.  At runtime, I see "cPropset[cProperty]" in the message
box plus a runtime error - Can't find handler near "of".

All largely academic but leaves me confused.


Pete
lcSQL Software <http://www.lcsql.com>
Home of lcStackBrowser <http://www.lcsql.com/lcstackbrowser.html> and
SQLiteAdmin <http://www.lcsql.com/sqliteadmin.html>


On Mon, Jan 27, 2014 at 2:05 PM, <dunbarx at aol.com> wrote:

> Pete.
>
>
> How are you selecting? I made a few controls, and did this in a button:
>
>
>
>
> on mouseUp
>    select control 1 and  control 1 and control 3
>    repeat for each line rLine in the selectedObjects
>          put the topLeft of rLine & return after sLocations
>    end repeat
>    answer sLocations
> end mouseUp
>
>
> No problems. When I first read your post I thought maybe a "do"
> construction might be in order, but it works just fine as is.
>
>
> Craig
>
>
>
>
> -----Original Message-----
> From: Peter Haworth <pete at lcsql.com>
> To: How to use LiveCode <use-livecode at lists.runrev.com>
> Sent: Mon, Jan 27, 2014 3:49 pm
> Subject: Dereferencing control ids
>
>
> Getting a problem trying to grab the topLeft of each control in the
> selectedObjects.  Code is as follows:
>
> repeat for each line rLine in the selectedObjects
>    put the topLeft of rLine & return after sLocations
> end repeat
>
> I get a runtime error on the "put" statement:
>
> (Chunk: error in object expression) near "field id 1004 of card id 1002 of
> stack "test"", char 23.
>
> The field reference is what's in rLine.
>
> I've also tried using a do statement resulting in a slightly different
> error - "error in source expression"
>
> If I enter - put the topleft of field id 1004 of card id 1002 of stack
> "test" - into the message box, I get a valid result.
>
> I have a horrible feeling this is going to be something really obvious but
> nevertheless, what am I doing wrong?
>
> Pete
> lcSQL Software <http://www.lcsql.com>
> Home of lcStackBrowser <http://www.lcsql.com/lcstackbrowser.html> and
> SQLiteAdmin <http://www.lcsql.com/sqliteadmin.html>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>



More information about the use-livecode mailing list