Positron Compiler Documentation

Bound

Source: Positron16 Compiler User Manual, PDF page 308

Syntax

Variable = Bound(Variable)

Overview

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.

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 = 32
  Declare Hserial_Baud = 9600      ' USART1 Baud rate
  Declare Hrsout1_Pin = PORTB.14   ' Select the pin for TX with USART1
  Dim MyByte as Byte
  CLKDIV = 0
                                     ' CPU peripheral clock ratio set to 1:1
  Write_OSCCONH(%00010000)
                                     ' Enable PLL
  RPOR7 = 3
                                     ' Make PPS Pin RP14 U1TX
  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
For Index = 0 To Bound(WordArray)
   HrsoutLn Dec Index, "=", Dec WordArray[Index]
Next
                              ' Loop until all elements scanned

See Also

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