Decimal Digit extract '?'
Source: Positron8 Compiler User Manual, PDF page 94
Syntax
Assignment Variable = Variable ? Variable
Overview
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).
Operands
Variable can be a constant, variable or expression. Assignment Variable can be any valid variable type.
Example
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
Note
Decimal Digit Extract does not support Float type variables.
See also the Dig function which performs the same task.