Mikroelektronika MIKROE-350 Datenbogen
![Mikroelektronika](https://files.manualsbrain.com/attachments/e0529b3b58069a916ad7bb89f7e9f5f0eda73421/common/fit/150/50/1b07b99aa3112e022a916b06db07f1f4f211e91d41878452d87c7638b1bf/brand_logo.gif)
CONSTANTS
Constant is a data whose value cannot be changed during the runtime. Using a con-
stant in a program consumes no RAM memory. Constants can be used in any
expression, but cannot be assigned a new value.
stant in a program consumes no RAM memory. Constants can be used in any
expression, but cannot be assigned a new value.
Constants are declared in the declaration part of the program or routine, with the fol-
lowing syntax:
lowing syntax:
const constant_name [as type] = value
Every constant is declared under unique
constant_name
which must be a valid
identifier. It is a tradition to write constant names in uppercase. Constant requires
you to specify
you to specify
value
, which is a literal appropriate for the given type.
type
is option-
al and in the absence of it , the compiler assumes the “smallest” type that can
accommodate value.
accommodate value.
Note: You cannot omit type if declaring a constant array.
Here are a few examples:
const MAX as longint = 10000
const MIN = 1000 ' compiler will assume word type
const SWITCH = "n" ' compiler will assume char type
const MSG = "Hello" ' compiler will assume string type
const MONTHS as byte[12] = (31,28,31,30,31,30,31,31,30,31,30,31)
const MIN = 1000 ' compiler will assume word type
const SWITCH = "n" ' compiler will assume char type
const MSG = "Hello" ' compiler will assume string type
const MONTHS as byte[12] = (31,28,31,30,31,30,31,31,30,31,30,31)
128
MIKROELEKTRONIKA
- SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Language Reference
mikroBasic PRO for AVR
CHAPTER 5