Examples, Variables, Special text – Nisus Writer Pro User Manual

Page 423: Replacement

Advertising
background image

Customizing & Automating Solutions

403

Table 30

Interpolated String Literals

Some controlling instructions (like “While” loops) can also take another command!as an argument.
However, these are special cases, so commands generally cannot!be used as arguments.

Examples

New '~/Documents/template.rtf'

This is equivalent to the following two lines:

$pathToTemplateFile = '~/Documents/template.rtf'
New $pathToTemplateFile

The following selects the cell which is the third down and the fourth across in a table:

Select Table Cell 3, 4

The next three lines replace the word NAME (case insensitive, which is the default) with Arthur
Jones:

$firstName = 'Arthur'
$secondName = 'Jones'
Find and Replace 'NAME', "$firstName $lastName"

Variables

You define variables in menu-command macros simply by assigning them a value. For instance:

$age = 24

Such variables are treated as pre-defined Perl Globals in every Perl block within the same macro.
Variables can also be assigned by using an instruction, for example:

$name = Prompt Input 'What is your name?'

More about instructions to follow.





Special Text

\n

\t

\\

\x

\u

\U

$varName

Replacement

Newline character.

Tab character.

Single backslash character (eg: "\").

The next two characters are treated as a Unicode code point (in hexadecimal).

The next four characters are"treated as a"Unicode code point"(in hexadecimal).

The next eight characters are"treated as a"Unicode code point"(in hexadecimal).

Current value of the named variable.

Advertising