Variables, Global variables – Teledyne LeCroy FireInspector - File Based Decoding User Manual
Page 11

5
CATC S
CRIPTING
L
ANGUAGE
1.0
C
HAPTER
2
Reference Manual
Values
result = null;
Variables
Variables are used to store information, or data, that can be modified. A variable can
be thought of as a container that holds a value.
All variables have names. Variable names must contain only alphanumeric charac-
ters and the underscore (
_
) character, and they cannot begin with a number. Some
possible variable names are
x
_NewValue
name_2
A variable is created when it is assigned a value. Variables can be of any value type,
and can change type with re-assignment. Values are assigned using the assignment
operator (
=
). The name of the variable goes on the left side of the operator, and the
value goes on the right:
x = [ 1, 2, 3 ]
New_value = x
name2 = "Smith"
If a variable is referenced before it is assigned a value, it evaluates to null.
There are two types of variables: global and local.
Global Variables
Global variables are defined outside of the scope of functions. Defining global
variables requires the use of the keyword
set
. Global variables are visible through-
out a file (and all files that it includes).
set Global = 10;
If an assignment in a function has a global as a left-hand value, a variable will not
be created, but the global variable will be changed. For example
set Global = 10;
Function()
{
Global = "cat";
Local = 20;
}