Reassigning stack names in behavior references
Jim Lambert
jiml at netrin.com
Thu Sep 11 13:52:51 EDT 2014
Behaviors are very useful. Scott Rossi gave an excellent presentation on them at the recent conference.
One thing that sometimes trips me up - I’ll assign a behavior to a bunch of controls then I’ll re-name the stack that contains the original behavior button.
Dumb :( because the controls can’t find the original reference button.
If you ever find yourself in that situation, here’s a script to rename the referenced stack names in one shot.
on updateBehaviorStackNames oldStackName
-- If you change the name of the stack that owns a behavior button, then all controls that have that behavior would fail to invoke it.
-- Use this handler to change the referenced stack in card controls that have behaviors.
-- It will replace the old stackname reference with the new stackname
if oldStackName is empty then
beep
answer error "Please pass old stack name."
end if
repeat with x = 1 to the number of controls
set the cursor to busy
put the behavior of control x into cBehavior
if cBehavior is empty then next repeat
replace oldStackName with the short name of this stack in cBehavior
set the behavior of control x to cBehavior
end repeat
end updateBehaviorStackNames
Jim Lambert
More information about the use-livecode
mailing list