Changing visibility of a bunch of objects

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Andycal
Posts: 144
Joined: Mon Apr 10, 2006 3:04 pm

Changing visibility of a bunch of objects

Post by Andycal » Sat Apr 17, 2010 9:42 am

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?

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Changing visibility of a bunch of objects

Post by jmburnod » Sat Apr 17, 2010 10:27 am

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
https://alternatic.ch

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4172
Joined: Sun Jan 07, 2007 9:12 pm

Re: Changing visibility of a bunch of objects

Post by bn » Sat Apr 17, 2010 10:36 am

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

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

Re: Changing visibility of a bunch of objects

Post by Klaus » Sat Apr 17, 2010 11:29 am

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

Andycal
Posts: 144
Joined: Mon Apr 10, 2006 3:04 pm

Re: Changing visibility of a bunch of objects

Post by Andycal » Sun Apr 18, 2010 1:02 pm

Thanks all, a mixture of all of these scripts has got it working just how I need it!

Post Reply