SizeOf
Positron16 · Revision 1.1.3.5 · PDF page 323
Syntax
Assignment Variable = SizeOf (Variable)
Overview
The SizeOf function returns the size of a standard variable, in bytes. If used with an array or String variable, it returns the amount of elements in the array or String.
Parameter
Variable can be a constant, variable or expression. Assignment Variable can be any valid variable type.
Example
' Create a loop for the amount of elements in an array
'
Device = 24FJ64GA002 ' Select the device to compile for
Declare Xtal = 16
Declare Hserial_Baud = 9600 ' USART1 Baud rate
Declare Hrsout1_Pin = PORTB.14 ' Select the pin for TX with USART1
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
