DelphiScript Statements & Operators Supported in Altium NEXUS
Created: January 09, 2020 | Updated: July 19, 2021
| Applies to versions: 3.1, 3.2, 4 and 5
Nexus message
This documentation page references Altium NEXUS/NEXUS Client (part of the deployed NEXUS solution), which has been discontinued. All your PCB design, data management and collaboration needs can now be delivered by Altium Designer and a connected Altium 365 Workspace. Check out the FAQs page for more information.
A statement in DelphiScript is considered 'simple' when it does not contain any other statements. Examples of simple statements are assignment statements and procedure calls.
In Delphi script, when values are assigned to variables, the colon-equal operator is used: :=
When testing for equality, the equality operator is used: =
Conditional Statements
DelphiScript has control statements that affect the flow of execution within a script. The most common control statement is the If..Then conditional statement.
If Then Statement
The If..Then statement is used for conditional control. The syntax is:
To avoid a complex set of If statements, these can often be replaced with Case statements. A case statement in an expression is used to select a value, a list of possible values, or a range of values.
Any types can be used in a Case statement because DelphiScript is an untyped language. Case statements can have an Else statement that is executed if none of the labels correspond to the value of the selector (within the Case Of condition).
The With statement is a DelphiScript shorthand. When referring to a record type variable (or an object), a 'with' statement can be used instead of repeating its name each time.
For loops are often used to initialize an array. The counter direction in a For..To..Do loop can be controlled by alternatively using the DownTo keyword to decrement the loop. DelphiScript provides the Break/Exit statement to exit a For..To..Do loop prematurely.
Repeat Until Loop
The Repeat statement is executed repeatedly until the Boolean expression is true. The Repeat statement is always executed at least once.
A While statement is similar to a Repeat statement except that the control condition is evaluated before the first execution of the statement sequence. Hence, if the condition is false, the statement sequence is never executed.
The Continue statement jumps over the body of a loop, similar to the Goto statement. The continue statement causes the executing script to pass to the next iteration in the current For, While or Repeat loop.
The Goto statement has the form Goto label which transfers the script execution to the statement marked by the specified label. To mark a statement, the label must be declared first and then the target statement preceded with the label and a colon: label: statement
A Label can be any valid identifier. The Label declaration and Goto statement must belong to the same code block within a script. Therefore it's not possible to jump into, or out of, a procedure or function.
The Exit statement immediately returns from a function or procedure. If you call Exit from within a Try..Finally block, the Finally part gets executed before the subroutine returns. If the Exit procedure is called from within the main body of the script, then execution of the script will terminate.
The Break statement causes the executing script to exit out of the current For, While or Repeat loop. Script execution continues from the subsequent executable line after the current loop.
In general, an expression is a valid combination of constants, variables, literal values, operators, and function results. Expressions are used to determine the value to assign to a variable, to compute the parameter of a function or to test for a condition. Expressions can include function calls.
DelphiScript has a number of logical, arithmetic, Boolean and relational operators. These operators are grouped by the order of precedence (see below), which is different to the precedence orders used by Basic, C, etc. For example, the AND and OR operators have precedence compared to the relational one.
If you write a<b and c<d, DelphiScript will do the AND operation first, resulting in an error. To prevent this problem and define the priority, each < expression needs to be enclosed in parentheses: (a<b) and (c<d);
The supported DelphiScript operators listed below are shown by their order of precedence.
Operators Grouped by Precedence
Note that Unary operators have the highest precedence.
Not
Boolean or bitwise NOT.
Multiplicative and Bitwise Operators
*
Arithmetic multiplication.
/
Floating point division.
div
Integer division.
mod
modulus (remainder of integer division).
and
Boolean or bitwise AND.
shl
Bitwise left shift.
shr
Bitwise right shift.
Additive Operators
+
Arithmetic addition, string concatenation.
-
Arithmetic subtraction.
or
Boolean or bitwise OR
xor
Boolean or bitwise EXCLUSIVE OR.
Relational and Comparison Operators (lowest precedence)
=
Test whether equal or not.
<>
Test whether not equal or not.
<
Test whether less than or not.
>
Test whether greater than or not.
<=
Test whether less than or equal to or not.
>=
Test whether greater than or equal to or not.
Also note that the ^ and @ operators are not supported by DelphiScript.
If you find an issue, select the text/image and pressCtrl + Enterto send us your feedback.