How to find references to a button in the behavior field

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
phaworth
Posts: 592
Joined: Thu Jun 11, 2009 9:51 pm

How to find references to a button in the behavior field

Post by phaworth » Sat Apr 17, 2010 1:30 am

I'm in the process of moving a library of objects with custom behaviors out of my application file and into a separate object library file so I can use from any other applications. The behavior filed of these objects all name buttons on a specific card in the original application and I need to change all the instances of these objects to name the equivalent buttons in my object library.

Is there some sort of Find command or any code I could write to do this? The find/replace command I see in the script editor only seems to look through scripts.

Thanks,
Pete

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: How to find references to a button in the behavior field

Post by mwieder » Sat Apr 17, 2010 2:24 am

The behavior property of an object is a long id, so it contains an absolute reference to the behavior object. I'd rather it were otherwise, but that's what we've got. I think the best thing might be for you to group the child objects, then iterate over the objects in the group, setting the behavior of each one (untested):

repeat for each control tControl in group x
set the behavior of tControl to the long id of button b
end repeat

phaworth
Posts: 592
Joined: Thu Jun 11, 2009 9:51 pm

Re: How to find references to a button in the behavior field

Post by phaworth » Sat Apr 17, 2010 5:53 am

I guess there's something weird going on with my behavior definitions because they aren't a long ID - they all look like 'button 1234 of stack "xyz" - unless I'm misunderstanding what a long id is.

That's kind of a side issue though because I still need to change them all. Ideally, what I'd like to do is write a script that repeats for every stack, for every card in each stack, and for every control on each card to look for non-empty behaviors. I have almost all of that figured out except that I can't figure out how to either get a list of all the stack names in my stack file or repeat through them some how. There has to be a way to do that?

Pete

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: How to find references to a button in the behavior field

Post by mwieder » Sun Apr 18, 2010 10:49 pm

put the substacks of this stack

Post Reply