Positron Compiler Documentation

Decimal Digit extract '?'

Positron8 · Revision 4.0.6.5 · PDF page 94

Assignment Variable = Variable ? Variable

In this form, the ? operator is compatible with the BASIC Stamp 2’s syntax. It returns the specified decimal digit of a 16-bit positive value. Digits are numbered from 0 (the rightmost digit) to 4 (the leftmost digit of a 16- bit number; 0 to 65535).

Variable can be a constant, variable or expression. Assignment Variable can be any valid variable type.

Device = 18F26K40             ' Select the device to compile for
Declare Xtal = 16  ' Tell the compiler the device will be operating at 16MHz
Declare Hserial_Baud = 9600   ' Set the Baud rate for HRsoutLn

Dim bMyLoop as Byte          ' Holds the loop for the For-Next
Dim MyWord as Word             ' Holds the result of the ?

MyWord = 9742
HRsoutLn MyWord ? 2           ' Display digit 2 (7)

For bMyLoop = 0 to 4
  HRsout MyWord ? MyLoop      ' Display digits 0 through 4 of 9742
Next
HRsout 13

Decimal Digit Extract does not support Float type variables.

See also the Dig function which performs the same task.

View original PDF page 94Open page in PDFOriginal PDF page 94