Positron Compiler Documentation

SizeOf

Source: Positron8 Compiler User Manual, PDF page 316

Syntax

Variable = SizeOf (Variable)

Overview

The SizeOf function returns the size of a standard variable, in bytes. If used with an array, it returns the amount of elements in the array.

Example

' Create a loop for the amount of elements in an array
'
  Device = 18F25K20
                                ' Use an 18F device
  Declare Xtal = 16
                                ' Tell the compiler the device is operating at 16MHz
  Declare Hserial_Baud = 9600 ' Choose the Baud rate for HRsoutLn
  Dim WordArray[10] as Word
                                ' Create an unsigned Word array variable
  Dim Index as Byte
                                ' Create a Byte variable
WordArray = 0, 100, 200, 300, 400, 500, 600, 700, 800, 900
Index = 0
Repeat
  HRsoutLn Dec Index, "=", Dec WordArray[Index]
  Inc Index
Until Index >= SizeOf(WordArray) ' Loop until all elements scanned

See Also

Bound, For…Next, Do…Loop, Repeat…Until, While…Wend