Comparison warning, Document operations, Environment properties – Nisus Writer Pro User Manual

Page 425: Macro document values

Advertising
background image

Customizing & Automating Solutions

405

# Reset the selection to the start of the document
Select All
Select Start
# As long as we find note references, superscript them
While Select Next Note Reference

Format:Baseline:Superscript

End

The “if” Boolean test in the Menu Command dialect is limited to testing for integer values and
strings, therefore a Perl block must be used when a While loop needs to test for a real (non-integer)
numeric value, or when any arithmetic calculations need to be performed.

Comparison warning

In the menu command dialect, comparisons are made numerically if the values being tested are
both numbers and are assigned to the variables without using quotes or are used in a binary
compare without quotes. When a number is assigned to a variable using quotes, or quoted in a
binary compare, it is assumed to be text and any compares will be textual. This is different from
Perl where all values are always stored as text until they are used in a numeric context. Therefore
Perl must use different binary operators for numeric and string compares, whereas the Nisus Menu
Command Dialect uses the same operators for both numeric and string compares.
Additionally, in the Nisus menu command dialect only whole numbers (positive or negative) can be
compared or stored in numeric variables and no arithmetical operations are possible - those must
be carried out in a Perl block.

Document operations

This section details the commands that operate on the documents as a whole. Arguments are
shown in italics.

New [templatePath]

Opens a new document. If a template path is provided will use the given file as a template.
If no template is provided the Nisus New File is used.

Save

Saves the document to its present location. If the document is unsaved then the user is
prompted.

Save As [path]

Saves the document to the specified path. If the path is not provided, then the user will be
prompted. Subsequent simple Save commands save to the specified path.

Save To [path]

Saves the document to the specified path, but maintains its current location, so that the
next plain Save command saves it in the current location. Again, if the path is missing, the
user is prompted.

Open path

Opens the file at the given path in Nisus Writer.

Open URL url

Opens the URL in the most appropriate application. Eg: “

http://www.nisus.com” will open

in Safari (or your default Web browser).

Environment properties

In the following examples, the names of variables on the left of the equals sign, which store the
respective property, can of course, be any names you want. The right side of the equals sign uses
reserved words only.

Macro document values

The following examples illustrate how to obtain the respective macro document (that is, the
document containing the macro code) properties.

$macro_file_name = Macro Property "file name"

The bare file name is, as you would expect, the file name without extension.

$bare_macro_file_name = Macro Property "file name without extension"
$pathToMacroFile = Macro Property "file path"

The file path is relative to the user’s home directory, that is it begins with "

~/"

$path_to_macro = Macro Property "absolute file path"

Advertising