Onetastic Macro Documentation >
>
Variables Variables
Variables in macros are similar to the concept of variables in any other programming language.
They can be used to temporarily store data by creating and subsequently initializing them with
assignment operators. Their values can then be further manipulated or used in
expressions:
$width = 5
$height = 7
$area = $width * $height
Objects themselves and the values of their properties can be stored into variables
and after being manipulated they can be stored back into properties:
foreach ($Cell in QueryObjects("Cell", GetCurrentPage()))
$value = $Cell.text_numeric
$value += 10
$Cell.text_numeric = $value
Variables are also used to store user input:
$dialog_box = DialogBox_Create("")
DialogBox_AddTextBox($dialog_box, "&Find what", $Search, "", false)
DialogBox_AddTextBox($dialog_box, "&Replace with", $Replace, "", true)
$Options = Array("Current page", "Current section", "Current notebook")
DialogBox_AddDropDown($dialog_box, "&Scope", $Scope, "Current section", $Options)
DialogBox_AddCheckBox($dialog_box, "Match &case", $MatchCase, false)
DialogBox_Show($dialog_box)
Data Types
Variables in macros aren't strongly typed. Therefore they can change from one type to the other.
For instance a value of "0" can be string type but modifying it by adding "1" will turn
it into numeric type. However a variable always have a deterministic data type
at any given point of macro execution. See Data Types for all the data types and possible
values.
|