Positron Compiler Documentation

Bound

Positron8 · Revision 4.0.6.5 · PDF page 300

Variable = Bound (Variable)

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

' Create a loop for the amount of elements in an array
'
  Device = 18F26K40          ' Tell the compiler what device to compile for
  Declare Xtal = 16      ' Tell the compiler the device will be 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 bIndex as Byte          ' Create a Byte variable

  WordArray = 0, 100, 200, 300, 400, 500, 600, 700, 800, 900

  For bIndex = 0 To Bound(WordArray)
     HRsoutLn Dec bIndex, "=", Dec WordArray[Index]
  Next                       ' Loop until all elements scanned

See Also: For…Next, Do…Loop, Repeat…Until, SizeOf, While…Wend

View original PDF page 300Open page in PDFOriginal PDF page 300