Positron Compiler Documentation

SizeOf

Positron8 · Revision 4.0.6.5 · PDF page 316

Variable = SizeOf (Variable)

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.

' 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

View original PDF page 316Open page in PDFOriginal PDF page 316