公式节点语法与文本编程语言的语法相似,与C语言一样,赋值结束后使用分号(;)。使用作用域规则在公式节点中声明变量。此外,请记住公式节点中允许的函数允许的运算符及其优先级

注: 如您了解C编程语言,可最有效的使用公式节点。LabVIEW帮助中未涉及关于C编程的相关主题。如需了解关于C编程语言的详细信息,可参考Brian W. Kernighan和Dennis M. Ritchie 编著的The C Programming Language或Herbert Schildt编著的Teach Yourself C

根据Backus-Naur范式(BNF表示法),公式节点语法总结如下。该总结涵盖了下列非终结符号:复合语句、标识符、条件表达式、数字、数组大小、浮点型、整型、左式、赋值运算符和函数。红色等宽粗体部分应全部复制。#表示其所属中心词的数量。

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:

下表是控制、条件、循环和switch语句在公式节点中的语法。

语句类型 结构 语法 说明/范例
控制语句 Break语句

break关键词用于在“公式节点”从最近的Do、For,或While循环以及switch语句中退出。
Continue语句

continue关键词用于在“公式节点”中将控制权传递给最近的Do、For,或While循环的下一次迭代。
条件语句

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语句

If-Else语句

循环语句

Do循环

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

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

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

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

Case语句

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: