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

Page 12

Advertising
background image

6

CATC Scripting Language for Bluetooth Analyzers

CATC

Manual Ver. 1.21

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.

Advertising