2 variables – Teledyne LeCroy LeCroy Analyzers File Based Decoding Manual User Manual
Page 11

File-based Decoding User Manual
Chapter 2: Values
LeCroy Corporation
5
2.2 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 characters
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 throughout 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 is not created,
but the global variable is changed. For example:
set Global = 10;
Function()
{
Global = "cat";
Local = 20;
}
creates a local variable called Local, which is only visible within the function Function.
Additionally, it changes the value of Global to "cat"
,
which is visible to all functions.
This also changes its value type from an integer to a string.