Livecode Wiki
Register
Advertisement

When a Get command is executed, LiveCode sends a Getprop message. That message will travel up the message path until it finds a Getprop handler to respond to that message, which is then executed. A Getprop handler will stop the execution of the Get command. If there is no such handler or that handler contains a Pass statement, the message will continue on to the engine. LiveCode will then complete the execution of the Get command.

An example of a Getprop handler:

getProp myCustomProperty
 return 23
end myCustomProperty

on MouseUp
 set the myCustomProperty of me to 11
 answer the myCustomProperty of me       -- answer = 23
end MouseUp

Notice that getprop usually doesn't change the value of the custom property.

Getprop is very useful when you need to create a dynamic complex property of an object. For example in a button script you can write:

getprop lenghtofstring
put the length of the text of field "myfield" into temp
return temp
end lenghtofstring

on MouseUp
answer the lenghtofstring of me
end MouseUp

Notice that you can use even non-existent custom properties, just the syntax must adhere to the custom properties syntax.

Advertisement