<< Click to Display Table of Contents >> Home mIoTa BASIC > mIoTa BASIC Language Reference > Constants |
A constant is a piece of data whose value is set at design time and cannot be changed during the runtime of a program. Constants can be used in any expression, but cannot be assigned a new value.
Constants can be declared anywhere in a program using the DEF command, but must be declared before they can be used.
def constant_name = value; |
Every constant must be declared under a unique name which must be a valid identifier.
The Data Type of a constant is automatically at deduced by the compiler at compile time using such clues as numeric value and format used in the source code.
Examples of Constant declarations and their use ..
def mynumber = 500; def hello_string = 'hello'; anothernumber = mynumber / 2; // results in 'anothernumber' becoming equal to 250 mystr = hello_string + ' me'; // results in mystr becoming 'hello me' |
Related topics: Identifier, Data Types.