FANDOM


In LiveCode, an object by default does not contain any custom properties. But you can add any number of custom properties to an object. You can add or change a custom property through script code. For example, a custom property can be given a value using the set command:

set the mycustprop of me to "Hello world"

If the above custom property already exists, then it will get a new value of "Hello world". if it does not exist, then it will be created and given the value "Hello world".

You cannot make changes to the values in a custom property. If you need to make changes, then put that value into a variable and make the changes. Use the set command to give that new value to the custom property. You can also use Setprop and Getprop to do some additional processing. For example, the following code is in the main stack and pCounter = 14.

on Mymessage1                                       -- start of handler
  put the pCounter of me into temp                  -- temp = 14
  add 1 to temp                                     -- temp = 15
  set the pCounter of me to temp                    -- pCounter = 15
end Mymessage1                                      -- end handler

Custom properties can be used instead of global variables. You can put data into it in one handler and withdraw that data for use in any other handler. For example, the above code is in the stack and the following code is in a button:

On MouseUp                                          -- start of handler
   put the pCounter of me into zemp                 -- zemp = 15
   answer ("Counter is " & zemp)                    -- answer = Counter is 15
end MouseUp                                         -- end handler
You can see and edit custom properties visually with the property inspector: as well:
CustomProperties

Custom property editor, in the custom property page

CustomProperty2

New custom property window, form version 8

Community content is available under CC-BY-SA unless otherwise noted.