How do I Locate Scripts or Custom Properties in my Project?

This lesson shows you how to identify entities in a project that have scripts or objects with custom properties attached to them. The process described here can be applied to any LiveCode stack.

Getting Started

Getting Started

For this example we use the top rated LiveCode stack Data Grids Tour. This stack is sufficiently large to demonstrate the generic nature of the code in this lesson. You can download the sample stack from this url: https://tinyurl.com/ya7ap3bl.

 

The Code

The Code

Open the Data Grids Tour in LiveCode and edit the stack script. Note that the on openStack handler is already present. Add the on showStackScriptsAndCustomProperties handler to the stack script. This code iterates through the main stack, substacks, the associated cards and the controls on the cards. At each level it looks for custom properties. This information is collected and then sent to the Message Box.

on showStackScriptsAndCustomProperties
   local tStack, tCard, tControl
   local tScript, tStacks, tSubStacks
   local tKey, tPropertyKeys
   put the name of this stack into tStacks
   put the substacks of this stack into tSubStacks
   repeat for each line tStack in tSubStacks
      put return & the name of stack tStack after tStacks
   end repeat
   put empty into msg
   repeat for each line tStack in tStacks
      put the script of the stack tStack into tScript
      put tStack && the number of lines of tScript & " line(s) of script" & return after msg
      put the customKeys of stack tStack into tPropertyKeys
      repeat for each line tKey in tPropertyKeys
         put tab & "Custom Property" && quote & tKey & quote & return after msg
      end repeat
      put 0 into tCard
      repeat for the number of cards in the stack tStack
         add one to tCard     
         put the script of card tCard of stack tStack into tScript
         put tab & the name of card tCard of stack tStack && the number of lines of tscript & \
               " line(s) of script" & return after msg
         put the customKeys of card tCard of stack tStack into tPropertyKeys
         repeat for each line tKey in tPropertyKeys
            put tab & tab & "Custom Property" && quote & tKey & quote & return after msg
         end repeat 
         put 0 into tControl
         repeat for the number of controls of card tCard of stack tStack
            add one to tControl           
            put the script of control tControl of card tCard of stack tStack into tScript
            put tab & tab & the name of control tControl of card tCard of stack tStack && \
                  the number of lines of tscript & " line(s) of script" & return after msg
            put the customKeys of control tControl of card tCard of stack tStack into \
                  tPropertyKeys
            repeat for each line tKey in tPropertyKeys
               put tab & tab & tab & "Custom Property" && quote & tKey & quote & \
                     return after msg
            end repeat        
         end repeat
      end repeat
   end repeat
end showStackScriptsAndCustomProperties

Calling the Handler

Calling the Handler

Open the Message Box and copy the following line into the command prompt and execute it:

send showStackScriptsAndCustomProperties to stack DataGridsTour

The output from this command is shown above. You can see details for stacks, cards, controls and custom properties. The process outlined in this lesson can be applied to any LiveCode stack for which you would like to find the custom properties.

1 Comments

William

Excellent!

Add your comment

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.