Variables, Global variables – Teledyne LeCroy Merlins Wand - CSL manual (CATC Scripting Language Manual) User Manual

Page 11

Advertising
background image

5

CATC Scripting Language for Bluetooth Analyzers

CATC

Manual Ver. 1.21

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;

}

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.

Advertising