Page 1 of 1
[13 Feb 2008] How to get the ID of an layer ?
Posted: Sat Jun 13, 2020 5:31 pm
by p-OS
Note: This is an archived post that was originally sent to the Hollywood mailing list on Wed, 13 Feb 2008 15:34:16 +0100
Hello,
imagine the following code:
Code: Select all
EnableLayers()
...do some stuff...
Box(10,10,200,100)
...do more stuff...
HideLayer(id)
How do I know the id of the layer associated with the box ?
One could assign a unique and unchangable String ID using
SetLayerName() that could be referred to at
HideLayer()
But to do that you still need to know the layer ID.
??
[13 Feb 2008] Re: How to get the ID of an layer ?
Posted: Sat Jun 13, 2020 5:31 pm
by PEB
Note: This is an archived post that was originally sent to the Hollywood mailing list on Wed, 13 Feb 2008 06:41:32 -0800 (PST)
All you need to do is name the box layer right after you draw it. You could do something like this:
Box(10,10,200,100) SetLayerName(GetAttribute(#DISPLAY, 0, #ATTRLAYERS), "BoxLayer")
[13 Feb 2008] Re: How to get the ID of an layer ?
Posted: Sat Jun 13, 2020 5:31 pm
by Clyde
Note: This is an archived post that was originally sent to the Hollywood mailing list on Wed, 13 Feb 2008 14:44:47 -0000
I want to add, that the main problem with that is, that the layer id changes, when I insert a new layer with the id 1, e.g. Depending on what "... do some stuff ..." is the Box would have the id 1. But what, if it was changed because a new layer was insert? How can you get the id of the box now?
[13 Feb 2008] RE: How to get the ID of an layer ?
Posted: Sat Jun 13, 2020 5:31 pm
by p-OS
Note: This is an archived post that was originally sent to the Hollywood mailing list on Wed, 13 Feb 2008 16:54:22 +0100
GetAttribute(#DISPLAY, 0, #ATTRLAYERS
Ah, that'S the trick
But can I be sure that it is really the id belonging to my object ? What happens if a SetInterval or Timer Function creating additional layers is executed between
Box() and
GetAttribute() call ?
[13 Feb 2008] RE: How to get the ID of an layer ?
Posted: Sat Jun 13, 2020 5:31 pm
by airsoftsoftwair
Note: This is an archived post that was originally sent to the Hollywood mailing list on Wed, 13 Feb 2008 22:00:58 +0100
GetAttribute(#DISPLAY, 0, #ATTRLAYERS
Ah, that'S the trick
But can I be sure that it is really the id belonging to my object ? What happens if a SetInterval or Timer Function creating additional layers is executed between
Box() and
GetAttribute() call ?
That won't happen. Hollywood does not do any random context switches to intervals and timers. Interval and timer functions are only called when Hollywood is in a
WaitEvent() loop.