Positron Compiler Documentation

Dig '?'

Source: Positron16 Compiler User Manual, PDF page 105

Syntax

Assignment Variable = pVariable ? pDigit

Or

Assignment Variable = Dig(pVariable, pDigit)

Overview

In the form of the ? Operator, it is compatible with the BASIC Stamp, and the melab's PICBASIC Pro compiler. ? 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).

Parameters

pVariable can be a constant, variable or expression. It holds the value to extract the digits from. pDigit can be a constant, variable or expression. It holds the digit to extract from the value Assignment Variable can be any valid variable type.

Example

Device = 24FJ64GA002
                                ' Select the device to compile for
Declare Xtal = 16
                         ' Tell the compiler the device will be operating at 16MHz
Declare Hserial_Baud = 9600    ' USART1 Baud rate
Declare Hrsout1_Pin = PORTB.14 ' Select the pin for TX with USART1
Dim bLoop as Byte
Dim MyWord as Word
PPS_Output(cOut_Pin_RP14, cOut_Fn_U1TX)  ' Make Pin RB14 U1TX
MyWord = 9742
Hrsout MyWord ? 2, 13
                                ' Display digit 2 (7)
For bLoop = 0 to 4
   HrsoutLn MyWord ? bLoop
                                ' Display digits 0 through 4 of 9742.
Next

Note

Dig does not support Double, Float or Dword type variables.