Find broken behaviours

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
trevix
Posts: 958
Joined: Sat Feb 24, 2007 11:25 pm
Location: Italy
Contact:

Find broken behaviours

Post by trevix » Thu Apr 01, 2021 2:52 pm

I have a stack with several nested objects that use behaviours, since group of them share the same scripts.
Now, I was able to mess things up and found that, here and there, there are objects that don't link anymore to an existing behaviour (red on the project browser).

Is there a way to obtain a list of these unlinked objects, so that I can fix them? (that is, put the correct path for the behaviour)
Thanks
Trevix
OSX 14.3.1 xCode 15 LC 10 DP7 iOS 15> Android 7>

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2718
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: Find broken behaviours

Post by jmburnod » Thu Apr 01, 2021 4:36 pm

Hi,
One way i use to find broken behaviors path for one card

Code: Select all

function getListControlsBadBEH
   put empty into rListControlsBadBEH
   repeat with i = 1 to the num of controls
      put the short name of control i into tName
      put the behavior of control i into tBEH
      if tBEH = empty then next repeat
      if there is a tBEH then
         next repeat
      else
         put the short name of this cd &"," & tName & "," & tBEH & cr after rListControlsBadBEH
      end if
   end repeat
   return rListControlsBadBEH
end getListControlsBadBEH 
Best regards
Jean-Marc
https://alternatic.ch

kdjanz
Posts: 300
Joined: Fri Dec 09, 2011 12:12 pm
Location: Fort Saskatchewan, AB Canada

Re: Find broken behaviours

Post by kdjanz » Thu Apr 01, 2021 8:53 pm

You can also look in the project browser.

Objects with a behaviour script have an extra icon over on the right hand side, which will let you edit the script if you double click it.
If it doesn't have the icon and it should, you can go into the property inspector and link it back up.

Good Luck

Kelly

trevix
Posts: 958
Joined: Sat Feb 24, 2007 11:25 pm
Location: Italy
Contact:

Re: Find broken behaviours

Post by trevix » Thu Apr 01, 2021 8:56 pm

Thanks Kelly, I knew about that.
But when they are deeply nested it is a pain to find them, particularly because the project browser is so crude
Trevix
OSX 14.3.1 xCode 15 LC 10 DP7 iOS 15> Android 7>

kdjanz
Posts: 300
Joined: Fri Dec 09, 2011 12:12 pm
Location: Fort Saskatchewan, AB Canada

Re: Find broken behaviours

Post by kdjanz » Thu Apr 01, 2021 9:03 pm

Then a script would be the route to go. The script could check if the control is on a list of objects that need behaviour 1 or 2 and then set the behaviour accordingly in the script. If you don't want to make a list of objects, you could use a custom property in each object with the name of the behaviour it should have. The script could then loop through every object, and if it had the magic property it would be reconnected to it's behaviour automagically.

An "automated" repair button if you will.

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”