Variables and Constants

Variables

A variable is a representation of data. The data stored in a variable can be either a string or a numeric, which can change dynamically during a program.

Strings can be of any size including the NULL string of 0 (zero) bytes in length.

In many systems, variables are "typed", i.e. they can only hold a certain type of data. The jBC language uses "typeless" variables, allowing any kind of data to be stored within them. In addition, there are no limitations on what may be stored in a byte within a variable. The full range of of 8 bit values, 0x00 to 0xFF (or UTF-8 characters, if Internationalization is being used) may be stored within a variable.

There is no limit to the number of variables that can exist within a jBC program.

A variable name identifies the variable and can contain almost any sequence of ASCII characters but it must start with an alphabetic character. A variable cannot contain spaces, commas, or mathematical operators (+, -, * /, ^, etc.)

A jBC reserved word cannot be used as a variable name and the compiler will signal an error condition if it detects the illegal use of a reserved word.

 

Constants

A constant is similar to a variable except that it holds a value that remains unchanged throughout the execution of a program.

The value of a constant may be either of a numeric or a literal string.

A string constant must be enclosed in single quotes, double quotes or forward slashes, e.g. "aString" or 'aString' or /aString/. Any of the enclosing characters can be included as part of the constant if the whole constant is enclosed between a different delimiter, e.g. /'a string with 'single' and "double" quotes/.

Examples

EQU PI TO 3.14159265359

Sets the value of PI to the numeric value of 3.14159265359

EQU PATH TO "C:\home"

Sets the value of PATH to the literal string value of "C:\home".


Knowledgebase Index