[13 Feb 2008] How to get the ID of an layer ?

Contains all messages from the Hollywood mailing list between 01/2006 and 08/2012
Locked
p-OS
Posts: 123
Joined: Mon Nov 01, 2010 11:56 pm

[13 Feb 2008] How to get the ID of an layer ?

Post 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.

??

PEB
Posts: 535
Joined: Sun Feb 21, 2010 1:28 am

[13 Feb 2008] Re: How to get the ID of an layer ?

Post 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")

User avatar
Clyde
Posts: 320
Joined: Sun Feb 14, 2010 12:38 pm
Location: Dresden / Germany

[13 Feb 2008] Re: How to get the ID of an layer ?

Post 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?
Currently using: Hollywood 8 with Visual Studio Code and hw4vsc

p-OS
Posts: 123
Joined: Mon Nov 01, 2010 11:56 pm

[13 Feb 2008] RE: How to get the ID of an layer ?

Post 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 ?

User avatar
airsoftsoftwair
Posts: 4350
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

[13 Feb 2008] RE: How to get the ID of an layer ?

Post 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.

Locked