Local variables, Constants – Teledyne LeCroy BPT - References Manual User Manual
Page 10

6
CATC S
CRIPTING
L
ANGUAGE
1.1
C
HAPTER
2
Reference Manual
Values
will create a local variable called
Local
, which will only be visible within the
function
Function
. Additionally, it will change the value of
Global
to
"cat",
which will be visible to all functions. This will also change its value type from an
integer to a string.
Local Variables
Local variables are not declared. Instead, they are created as needed. Local
variables are created either by being in a function's parameter list, or simply by
being assigned a value in a function body.
Function(Parameter)
{
Local = 20;
}
This function will create a local variable
Parameter
and a local variable
Local
,
which has an assigned value of 20.
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 un-
derscore (
_
) 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.