Variables

Variables in the source code are Identifier named memory cells in RAM (SRAM) or eeprom (eRAM). You can assign values to them and readout their value somewhere else. Detailed description (Wikipedia)

Dimensioning

Variables are declared by Dim (RAM) and/or eeDim (eeprom).

Methods/Attributes

Variables have Object features:

features of numeric standard variables (boolean, byte, word, integer, long, single, ..)
Name Description Type read/write
.0-x1) Bit n of the variable value boolean read+write
.LowNibble Low-Nibble of the variable value byte read+write
.HighNibble High-Nibble of the variable value byte read+write
.Nibblen Nibble n (1-8) of the variable value byte read+write
.Byten2) Byte n (1-4) of the variable value byte read+write
.LowByte3) Low-Byte of the variable value byte read+write
.HighByte4) High-Byte of the variable value byte read+write
.LowWord5) lower Word of the variable value word read+write
.HighWord6) higher Word of the variable value word read+write
.Reverse7) reverse the Byte order, see also Ce16(), Ce32() word, long read
.Addr8) Address of the variable 9) word read
.Ptr10) Address of the memory blocks word read
.SizeOf Read the number of Bytes the variable reserves. byte read
Methods of Byte and Word arrays
Name Description
.Sort Sort array data in ascending order (very fast sorting algorithm)

User defined Data Types

The elements Struct inherit Methods/Attributes.

String and MemoryBlock

The data type String and MemoryBlock have further Methods and Attributes.

Usage

Variables must be declared before they can be accessed. Variables store data values of their Data Type. See also: Dim, Chapter "Visibility of Variables"

Accessing individual Bits of a variable

A ssen above, you can access individual bytes for read and write operations. You may also access a Bit via another variable which has that Bit number: Example:

Access via a constant value executes faster: Example:

Example

dim a,b as byte
dim c as word
dim s as string
c=&ha1b2      ' Assign value, Hexa decimal (lie in reverse order in memory, Hex always Big-endian)
a=c.LowByte   ' read low Byte of the variable value, result: &hb2
b=c.HighByte  ' read High-Byte of the variable value, result: &ha1
c.LowByte=b   ' reverse and write
c.HighByte=a
c.0=1         'set Bit 0 in c
a=b.7         'read Bit 7 of b
a=3
c=b.a         ' read Bit 3 of b, Bit number is in a
Print "&h"+hex(c)  ' Display: &hb2a1
s = "Hallo"        ' assign text
a = s.ByteValue(1) ' Read decimal value of the 1. character of the string

See also

1) All numeric data types
2) only long, single
3) , 4) only word, integer
5) , 6) only long, longint, single
7) only long, longint, integer, word
8) All numeric data types and structures. The start address of Arrays
9) relevant to the memory block in which the variable lies, RAM or eeprom.
10) The intrinsic data type string, memoryblock