Path from group to card

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
david.silmanBUSrUeQ
Posts: 44
Joined: Thu Jul 19, 2012 1:49 pm

Path from group to card

Post by david.silmanBUSrUeQ » Wed Aug 22, 2012 3:33 pm

Ok guys, I'm making my own control, effectively a data tree (yes I know there are ones out there that I could use, but I want to make my own)

the situation is, I want to keep the code as separate from the control as possible, so I'm designing the elements on a stack that will effectively be used as a library (henceforth referred to as the library stack)
The code for the control will sit on the library stack and the actual grouped objects will call the commands and functions that they need, basically trying to make it into a class as much as livecode can do.

The problem is that when I copy the tree to a new card/stack, I need to know the exact number of groups it is embedded in, as it could vary, this mainly affects things like changing images

Code: Select all

set the filename of img "img" of group "...." and so on on card "card ..." on stack "stack ..."
but so far I've found that to do something like that you need to specify each and every group all the way up to the card, such:

Code: Select all

set the filename of img "img" of group "a" of group "b" of group "c" ... of group "n" on card...
is there any simple way of doing this? Or am I going to have to restrict it in some way?

Cheers
David

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

Re: Path from group to card

Post by Klaus » Wed Aug 22, 2012 3:44 pm

Hi David,
david.silmanBUSrUeQ wrote:...but so far I've found that to do something like that you need to specify each and every group all the way up to the card, such:...
I'm afraid that's the way LiveCode works, you need to exactly address objects.

Maybe you could use some "getprop" or "setprop" handlers in the groups so they can reference "me" in the scripts.
But I have no idea of your app design, so I can only guess vaguely 8)


Best

Klaus

david.silmanBUSrUeQ
Posts: 44
Joined: Thu Jul 19, 2012 1:49 pm

Re: Path from group to card

Post by david.silmanBUSrUeQ » Wed Aug 22, 2012 4:14 pm

Thanks for the fast reply.

How could I use setProp and getProp to allow the objected to be referred to as "me"?

I'll try and explain it a bit more, sorry if this is more confusing:

I have a stack that I'm effectively using as a library, on this stack I have my objects and code, the code being on the card itself and the object's script calls the commands from the cards script.

The control would then be copied to wherever it's needed. But that could be inside any number of groups.

cheers
David

Post Reply