Tutorial

Getting Started with Macros

Macro Editor

User Interface

Editing Macro Statements

Expression Editor

How To

Using variables

Finding and modifying objects

Creating new page content

Asking for user input

Sorting objects

Macro Logging

Sample Macros

Concepts

Expressions

Objects

Properties

Variables

Data Types

Arrays

Functions

Literals

Operators

Comments

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:

ExpandForEach ($Cell in QueryObjects("Cell", GetCurrentPage())) $value = $Cell.text_numeric $value += 10 $Cell.text_numeric = $value

Variables are also used to store user input:

// Create a dialog box with some controls $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) // Now show the dialog box, the user choices are stored in $Search, // $Replace, $Scope and $MatchCase variables after this call 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.

Reference

Statements

ForEach

If

Else

While

Expression

Comment

Break

Continue

Hierarchy Objects

NotebookRoot

Notebook

SectionGroup

Section

Page

Page Objects

Title

Outline

Table

Column

Row

Cell

Paragraph

Text

Image

EmbeddedFile

Tag

Other Objects

DialogBox

Functions

Array Functions

Date/Time Functions

Dialog Box Functions

Macro Execution Functions

Object Functions

String Functions