D.4 constants, D.5 expressions, Constants expressions – Teledyne LeCroy Merlins Wand - Users Manual User Manual

Page 275

Advertising
background image

259

CATC M

ERLIN

S

W

AND

2.00

C

HAPTER

D

User’s Manual

CATC Scripting Language

This function will create a local variable Parameter and a local variable
Local

, which has an assigned value of 20.

D.4 Constants

A constant is similar to a variable, except that its value cannot be changed.
Like variables, constant names must contain only alphanumeric characters
and the underscore ( _ ) character, and they cannot begin with a number.

Constants are declared similarly to global variables using the keyword
const

:

const CONSTANT = 20;

They can be assigned to any value type, but will generate an error if used in
the left-hand side of an assignment statement later on. For instance,

const constant_2 = 3;

Function()
{

constant_2 = 5;

}

will generate an error.

Declaring a constant with the same name as a global, or a global with the
same name as a constant, will also generate an error. Like globals, constants
can only be declared in the file scope.

D.5 Expressions

An expression is a statement that calculates a value. The simplest type of
expression is assignment:

x = 2

The expression x = 2 calculates 2 as the value of x.

All expressions contain operators, which are described in Section D.6,
“Operators,” on page 261.
The operators indicate how an expression should
be evaluated in order to arrive at its value. For example

x + 2

says to add 2 to x to find the value of the expression. Another example is

Advertising