Tutorial

Getting Started with Macros

Macro Editor

User Interface

Menus and Toolbar

Editing Macros

Macro Debugging

How To

Using variables

Finding and modifying objects

Creating new page content

Asking for user input

Storing persistent data

Using binary data

Sorting objects

Macro menus

Bulleted and numbered lists

Sample Macros

Concepts

Expressions

Objects

Properties

Variables

Data Types

Arrays

Functions

Literals

Operators

Comments

Last updated on: September 02, 2024
Also available as a single HTML file

Onetastic Macro Documentation > Concepts > Expressions

Expressions

Macro statements mostly evaluate expression to read or modify data. Expressions can be used to assign variables, access object properties, call functions and do arithmetic, logical or comparison operations. They can also provide literal values.

// Literal values: strings, numeric values and booleans "String Literal" 1234 3.5 true // Variables $name $format // Assignment $i = 0 $i += 1 $x = true $x &&= false $s = "text" $s &= " more text" // Arithmetic 3 - (5 * 2) $x || $y // String concatenation "text" & $str & " more text" // Comparison 7 > 4 "text" != $x // Unary sign and logical not +3 -5 !$a // Ternary operator ?: ($x > 3) ? "yes" : "no" // Function Calls String_Split($str, ";") DialogBox_Create("message") // Property access GetCurrentPage().name $Section.color // Array index $names[0] $multi_dim_arr[0][1][2] $Section.pages[1]

A more complex expression can combine all of these simpler expressions:

"Last page in the section has " & ((String_Length($Section.pages[Array_Length($Section.pages) - 1].name) > 0) ? "a name" : "no name")

Reference

Statements

Hierarchy Objects

Page Objects

Other Objects

Functions

Array Functions

Color Functions

Data Store Functions

Date/Time Functions

Dialog Box Functions

Macro Execution Functions

Macro Menu Functions

Object Functions

Special Functions

String Functions

Window Functions