Grouping all controls via a script

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
trjenks
Posts: 1
Joined: Tue Jul 06, 2010 12:31 am

Grouping all controls via a script

Post by trjenks » Tue Jul 06, 2010 12:50 am

This seems like a simple problem, but I can't find a solution:

I'm trying to group all the controls that are on a card within a script. On the card there could be any number of labels, buttons, etc--basically anything that can be grouped. I iterate through the controls of the card, and append the name of each to a string called allcardcontrols, and then try to group them via these lines:

Code: Select all

repeat with x =1 to the number of controls of this card
   put the name of control x of this card && "and " after allcardcontrols
end repeat
delete the last word of allcardcontrols
group allcardcontrols
But I get the error "Error description: Chunk: error in object expression" in the last line.
allcardcontrols contains the appropriate text to meet the requirements for the objectlist of the group command
(in my case--allcardcontrols: button "Button" and field "FY100" and graphic "Rectangle")

the command: group allcardcontrols <<does not work,
but the command: group button "Button" and field "FY100" and graphic "Rectangle" <<does work.

how do I get the script to use the content of the variable allcardcontrols with the group command?

Curry
Posts: 111
Joined: Mon Oct 15, 2007 11:34 pm
Contact:

Re: Grouping all controls via a script

Post by Curry » Tue Jul 06, 2010 7:30 am

The problem is that group can't take all the rest as a parameter; you have to issue the whole thing as a statement.

This is where the "do" command comes in. It allows you to put text together and then issue it just like regular statement.
Best wishes,

Curry Kenworthy

LiveCode Development, Training & Consulting
http://livecodeconsulting.com/

WordLib: Conquer MS Word & OpenOffice
SpreadLib: "Excel-lent" spreadsheet import/export
http://livecodeaddons.com/

Klaus
Posts: 14208
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Grouping all controls via a script

Post by Klaus » Tue Jul 06, 2010 10:55 am

Hi trjenks,

no need to use "DO"!

Code: Select all

...
repeat with x =1 to the number of controls of this card
    set the selected of control x to true
end repeat
group
## Done :)
...
Best

Klaus

Post Reply