operator:w |
The operator is the type of operation you want to carry out on a variable. They work by looking at the value on the right of the operator and changing the left hand value accordingly. All arithmetic is done with 32-bit integers. Numerical results are stored back into variables as a string of ASCII digits. Variables that do not begin with ASCII digits have the value '0'. This is also true of variables which do not exist, or to which a value has never been assigned.
= |
Sets variable to value. The simplest way of giving a variable a value is to create a new variable using the =operator. The example below creates three new variables. If the variable already existed these macros would reset them to the new values. |
^num=123
|
1
|
^string1=Dave
|
2
|
^num=^Dave
|
3
|
+ |
Increases the value of variable by value. Two ++ is a short-cut for increasing the value of variable by 1: |
- |
Decreases the value of variable by value. Two -- in a row is a short-cut for decreasing the value of variable by 1.
|
* |
Multiplies the value of variable by value. |
example.ref entityref="A3B2.Ex.DecreaseValueofVariable_en" type="include"/>
/ |
Divides the value of variable by value. |
} |
Makes the contents of variable have exactly value characters, by truncating it or by adding spaces on the left. The example below makes ^string have five characters, making its final value ...Ad (where points represent a space character): |
{ |
Makes the contents of variable have exactly value characters, by truncating it or by adding spaces on the right. The example below makes ^string1 have five characters, making its final value Adv.. (where points represent a space character): |
^string1=Adv
|
1
|
^string1{5
|
2
|
In this case the result will be "Adv##" (# indicates space).
. |
Appends value to the end of the contents of variable. The example below sets two variables and then concentrates them. The result is that ^string 1 will now contain 'HelloDave': |
! |
Gets the length of a string. The example below gives ^string1 a value of 4, this being the number of characters in the word 'Four'. |
[ |
Replaces the contents of variable with a sub-string of itself, counting from the v1st to the v2nd characters where v1 is the first character, numbered 1, in the string. The last character's number is the same as the length of the string. If v1 is zero or not present it defaults to the first character of the string. If v2 is zero or not present it defaults to the last character of the string. If you wish you can add a ] at the end of the line. This has no effect and is for readability only. The example below effectively cuts off the first character of ^string1, which becomes 'def)' |
] |
The ] operator is similar to [, but works from the end of the string. v1 is therefore the last character in the string. v2, is the first character in the string. If v2 is zero or not present it defaults to the first character of the string. If v1 is zero or not present it defaults to the last character of the string. If you wish you can add a [ at the end of each line. This has no effect and is for readability only. |
A problem with using the wdb macro to extract the data from a Arbortext APP dialogue box is that in many cases the data you want to examine is enclosed in either ( ) or [ ] characters, representing either the system or document defaults for a particular setting. In order to examine these sensibly you must strip the unwanted ( ) or [ ] characters:
A slightly simpler version of the same script avoids using loops by including the operations on the ^typeface variable on the same line as the tests. This makes the script a few characters longer, admittedly, but perhaps gains in clarity:
^parenthesis=(
|
1
|
^bracket=[
|
2
|
wdb "typeface"
|
3
|
tf
|
4
|
^tmp=^typeface
|
5
|
^tmp[..1
|
6
|
?=^tmp,^parenthesis }strip
|
7
|
?=^tmp,^bracket }strip
|
8
|
}nextstep
|
9
|
:strip
|
10
|
^typeface[2..
|
11
|
^typeface]2..
|
12
|
:nextstep
|
13
|
^parenthesis=(
|
14
|
^bracket=[
|
15
|
wdb "typeface"
|
16
|
tf
|
17
|
^tmp=^typeface
|
18
|
^tmp[..1
|
19
|
?=^tmp,^parenthesis (^typeface[2..):(^typeface]2..)
|
20
|
?=^tmp,^bracket (^typeface[2..):(^typeface]2..)
|
21
|
The following examples will assume that this assignment has taken place:
Then:
-
result:
- ^sh = el
-
result:
- sh = "hel"
-
result:
- sh = "llo"
-
result:
- sh = "ll"
This example crops characters from a string using variable values.
The following examples will assume that this assignment has taken place:
^lg=abcdefghijklmnopqrstuvwxyz
|
1
|
^a=3
|
2
|
^b=5
|
3
|
^c=15
|
4
|
Then:
lg = "cdefgh"
lg = "opqrstuvwxyz"
lg = "lmnopqrstuv"
lg = "xyz"
@ |
Retrieves the position of a single specified character in a line. The example below gets position of the 'd' character, set in ^var from the contents of the ^string variable |
Resulting in the value of ^var being '4'.
$ |
Two commands have been implemented for converting between deci-microns and any of Arbortext APP units. You may come across this when using floating points with variables and measurement getvars. |
# |
The second operator converts from unit form to deci-microns. The syntax of 'mm' is the same as for the '$' operator, but this time it provides the default units if none are present in ^variable. A valid default must always be specified, even if ^variable is known to contain its own unit type. |
| |
Logical or used to perform binary bitwise arithmetic on two binary values. In the result digits which are set in either value are returned with a value of 1. |
: |
Logical and used to perform binary bitwise arithmetic on two binary values. In the result digits which are set in both values are returned with a value of 1. |
^ |
Logical xor used to perform binary bitwise arithmetic on two binary values. |
% |
Modulus (remainder of division). |
|