beautypg.com

3 constants – Teledyne LeCroy Protocol Analyzers File-Based Decoding User Manual User Manual

Page 12

background image

Chapter 2: Values

File-based Decoding User Manual

6

LeCroy Corporation

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 creates a local variable Parameter and a local variable Local, which has

an assigned value of 20.

2.3 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 underscore ( _ )

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 generates an error if used in the left-hand
side of an assignment statement later on. For example:

const constant_2 = 3;

Function()
{

constant_2 = 5;

}

generates an error.

Declaring a constant with the same name as a global, or a global with the same name as
a constant, also generates an error. Like globals, constants can only be declared in the
file scope.