Page 1 of 1

Grouping all controls via a script

Posted: Tue Jul 06, 2010 12:50 am
by trjenks
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?

Re: Grouping all controls via a script

Posted: Tue Jul 06, 2010 7:30 am
by Curry
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.

Re: Grouping all controls via a script

Posted: Tue Jul 06, 2010 10:55 am
by Klaus
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