Page 1 of 1
Changing visibility of a bunch of objects
Posted: Sat Apr 17, 2010 9:42 am
by Andycal
I've got 10 or so objects of mixed type on a card which should appear based on a number in a field. So, to make it easy I've given them all a name that ends in the number in which they should appear, for example, lbl3, graphic3 etc. My idea was to put all the objects into a varible (comma seperated) and then go through them one by one, but I've tried this and realised that I need to reference the object type too. I think.
So, I need to know that lbl3 is a lable so I can "set the visible of lbl "lbl3" to true".
Or am I missing a trick? Ideally I just want to "Set all objects ending in 'x' to visible".
Is there an easy way to do this or do I need to reference each object individually?
Re: Changing visibility of a bunch of objects
Posted: Sat Apr 17, 2010 10:27 am
by jmburnod
Hi Andy,
I suggest using the "Do" command to cook a list (for exemple a card customprop )
Code: Select all
on ShowObj pVis
put "btn MyBtn,fld MyFld,img MyImage" into pListeObj
SetVisObj pListeObj,pVis
end ShowObj
on SetVisObj pListeObj,pVis
repeat for each items UnObj in pListeObj
do "set the visible of UnObj to pVis"
end repeat
end SetVisObj
Best
Jean-Marc
Re: Changing visibility of a bunch of objects
Posted: Sat Apr 17, 2010 10:36 am
by bn
Andy,
try
Code: Select all
on mouseUp
repeat with i = 1 to the number of controls
if last char of the short name of control i = "3" then set the visible of control i to not the visible of control i
end repeat
end mouseUp
is that what you want?
regards
Bernd
Re: Changing visibility of a bunch of objects
Posted: Sat Apr 17, 2010 11:29 am
by Klaus
Hi Andy,
if you do not have different objects with the same name like: button "xyz" AND field "xyz", then you can use the keyword "control"!
...
set the vis if CONTROL "XYZ" to true
## No need to specify "button" or "field" here!
...
Hint:
...
## You wrote:
set the visible of lbl "lbl3" to true
...
There is no control type "lbl", this is a field!
Best
Klaus
Re: Changing visibility of a bunch of objects
Posted: Sun Apr 18, 2010 1:02 pm
by Andycal
Thanks all, a mixture of all of these scripts has got it working just how I need it!