LiveCode Builder Module Level Variables
A variable definition defines a module-scope variable. In a widget module, such variables are per-widget (i.e. instance variables). In a library module, there is only a single instance (i.e. a private global variable). Module-scope variables in LCB are similar to script local variables in LiveCode Script.
The syntax for declaring variables is
Variables whose type has a default value are initialised to that value at the point of definition. The default values. For a list of default values see the ‘Variables’ section of the LiveCode Builder Language Reference Guide. The guide can be found under the Guides tab of the Dictionary or in the Additional Resources section of the course.
Variables whose type do not have a default value will remain unassigned and it is a checked runtime error to fetch from such variables until they are assigned a value.
Variable declararions
In this widget we will use 1 module level variable to store the value of the rotation property of the widget.
The value of the rotation property must be a number so we define the type as such.
The variable will be an module level instance variable, so we prepend the variable name with a lower case ‘m’ to make it easily identifiable as such.
Add the variable definition to the widget code.
use com.livecode.widget use com.livecode.engine use com.livecode.library.widgetutils metadata title is "Rotated Text" metadata author is "Elanor Buchanan" metadata version is "1.0.0" variable mRotation as Number end widget