Inc
Source: Positron8 Compiler User Manual, PDF page 335
Syntax
Inc Variable {, IncrementVariable}
Overview
Increment a variable i.e. Variable = Variable + 1, or increment a variable by the value held in parameter 2. i.e. Variable = Variable + IncrementVariable
Parameters
Variable is a user defined variable that will be incremented IncrementVariable is an optional variable or expression or constant that will be added to the first variable.
Example1
Device = 18F25K20
' Select the device to use
Declare Xtal = 16
' Tell the compiler the device is operating at 16MHz
Declare Hserial_Baud = 9600
' Set the Baud rate for the HRsoutLn command
Dim MyByte as Byte = 1
' Create a variable and give it an initial value
Repeat
' Create a loop
HRsoutLn Dec MyByte
' Transmit the ASCII value to a serial terminal
DelayMs 200
' A delay so the value can be seen changing
Inc MyByte
' Increment the variable MyByte by 1
Until MyByte > 10
' Loop until the variable reaches 10 or over
The above example shows the equivalent to the For-Next loop: -
For MyByte = 1 to 10 : Next
Example 2
Device = 18F25K20
' Select the device to use
Declare Xtal = 16
' Set its frequency
Declare Hserial_Baud = 9600
' Set the Baud rate for the HRsoutLn command
Dim MyWord as Word = 1
' Create a variable and give it an initial value
Repeat
' Create a loop
HRsoutLn Dec MyWord
' Transmit the ASCII value to a serial terminal
DelayMs 200
' A delay so the value can be seen changing
Inc MyWord, 10
' Increment the variable MyWord by 10
Until MyWord > 100
' Loop until the variable reaches 100 or over