Positron Compiler Documentation

Clear

Source: Positron16 Compiler User Manual, PDF page 329

Syntax

Clear Variable or Variable.Bit or Pin Number

Clear

Overview

Place a variable or bit in a clear state. For a variable, this means loading it with 0. For a bit this means setting it to 0.

Clear has another purpose… If no variable is present after the command, all user RAM within the device is cleared when the device first powers up, or a reset is implemented. Variables that are created with assignments, and Static variables will still hold their values because the Clear command becomes a directive, and signals to the compiler to add a block of code at the beginning of the user’s program, to clear the RAM before the variables are created.

Parameters

Variable can be any variable or register. Variable.Bit can be any variable and bit combination. Pin Number can only be a constant that holds a value from 0 to the amount of I/O pins on the device. A value of 0 will be PORTA.0, if present, 1 will be PORTA.1, 8 will be PORTB.0 etc…

Example1

Clear
                    ' Clear all RAM area
Clear Var1.3
                    ' Clear bit 3 of Var1
Clear Var1
                    ' Load Var1 with the value of 0
Clear STATUS.0
                    ' Clear the carry flag high
Clear MyArray
                    ' Clear all of an Array variable. i.e. reset to zero’s
Clear MyString
                    ' Clear all of a String variable. i.e. reset to zero’s
Clear Pin_A0      ' Clear PORTA.0

Notes

There is a major difference between the Clear and Low command. Clear does not alter the TRIS register if a Port is targeted.

See Also

Set, Low, High, PinClear, PinSet, PinLow, PinHigh.