The Formula Node syntax is similar to the syntax used in text-based programming languages. Remember to end assignments with a semicolon (;) as in C. Use scope rules to declare variables in Formula Nodes. Also, keep in mind the allowed functions and the allowed operators and their precedence in the Formula Node.

Note You can use Formula Node most effectively if you are familiar with the C programming language. LabVIEW Help assumes you are familiar with C and does not contain any topics related to programming in C. Refer to The C Programming Language by Brian W. Kernighan and Dennis M. Ritchie or Teach Yourself C by Herbert Schildt for more information.

The Formula Node syntax is summarized below using Backus-Naur Form (BNF notation). The summary includes non-terminal symbols: compound-statement, identifier, conditional-expression, number, array-size, floating-point-type, integer-type, left-hand-side, assignment-operator, and function. Symbols in red bold monospace are terminal symbols given exactly as they should be reproduced. The symbol # denotes any number of the term following it.

statement-list:

statement:

assignment:

expression:

left-hand-side:

array-subscription:

assignment-operator: one of the following

binary-operator: one of the following

unary-operator: one of the following

argument-list:

constant:

compound-statement:

The following table provides the Formula Node syntax for control, conditional, iterative, and switch statements.

Statement Type Construct Grammar Description/Example
Control Statement Break Statement

Use the break keyword to exit the nearest Do, For, or While Loop or switch statement in the Formula Node.
Continue Statement

Use the continue keyword to transfer control to the next iteration of the nearest Do, For, or While Loop in the Formula Node.
Conditional Statement

if (y==x && a[2][3]<a[0][1]) { 
    int32 temp;
    temp = a[2][3];
    a[2][3] = y;
    y=temp;
    }
else
    x=y;
If Statement

If-Else Statement

Iterative Statement

Do Loops

do {
    int32 temp;
    temp = --a[2]+y;
    y=y-1;
    }
while (y!=x && a[2]>=a[0]);
For Loops

for (y=5; y<x; y*=2) {
    int32 temp;
    temp = --a[2]+y;
    x-=temp;
    }
While Loops

while (y!=x && a[2]>=a[0]) {
    int32 temp;
    temp = --a[2]+y;
    y=y-1;
    }
Switch Statement

switch(month){
    case 2: days = evenyear? 29: 28; break;
    case 4:case 6:case9: days = 30; break;
    default: days = 31; break;
    }
Case Statement List

Case Statement

variable-declaration:

array-index-list:

type-specifier:

floating-point-type:

integer-type:

non-digit: one of the following

digit: one of the following

nonzero-digit: one of the following

binary-digit: one of the following

octal-digit: one of the following

hex-digit: one of the following

identifier:

non-first-character:

number:

integer-constant:

decimal-constant:

binary-constant:

octal-constant:

hex-constant:

float-constant:

fraction:

exponent-part:

sign: one of the following

comment: