FANDOM


In LiveCode, an object by default does not contain any custom properties. But you can add, change or delete any number of custom properties of an object by using the property inspector. You can also add or delete any number of custom property by using 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 can make changes to the value in a custom property by using the property inspector. You cannot make changes to the values in a custom property by using script code. However if you need to make changes, then put the value of a custom property into a variable. And make the change to the value of the variable. Then set the value of the custom property to that new value. You can also use Setprop and Getprop to do some additional processing.

In the following example, the 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.