Dimension a variable.


DIM var AS [XRAM/IRAM] type


var Any valid variable name such as b1, i or longname. var can also be an array : ar(10) for example.

type Bit/Boolean, Byte, Word, Integer, Long, Single or String
XRAM Specify XRAM to store variable in external memory
IRAM Specify IRAM to store variable in internal memory (default)

A string variable needs an additional length parameter :
Dim s As XRAM String * 10
In this case, the string can have a length of 10 characters.

Note that BITS can only be stored in internal memory.

Difference with QB
In QB you don't need to dimension each variable before you use it. In BASCOM you must dimension each variable before you use it.
Also the XRAM/IRAM options are not available in QB.

See Also

' (c) 1997-2000 MCS Electronics
' file: DIM.BAS
' demo: DIM

Dim B1 As Bit 'bit can be 0 or 1

Dim A As Byte 'byte range from 0-255
Dim C As Integer 'integer range from -32767 - +32768
Dim A As String * 10 'string with length of 10 characters

Dim ar(10) As Byte 'dimension array
'assign bits
B1 = 1 'or
Set B1 'use set

'assign bytes
A = 12
A = A + 1

'assign integer
C = -12
C = C + 100
Print C

For a = 0 to 7

Set C.A 'set bit and use an index for the bit number