November 22, 2024, 01:00:21 AM

News:

Got VSA?  Want to use your Prop-SX?  Now you can!  See the VSA section of the Library forum for Prop-SX code that works with VSA.


Help with DIG Command

Started by samsam, March 19, 2008, 10:28:15 AM

Previous topic - Next topic

samsam

This from the Basic Stamp Editor Help Say this About DIG Command

DIG Returns Specified Digit of Number
The Digit operator (DIG) returns the specified decimal digit of a 16-bit positive value. Digits are numbered from 0 (the right-most digit) to 4 (the left-most digit of a 16-bit number; 0 to 65535).


value   VAR     Word
idx     VAR     Nib

Main:
  value = 9742
  DEBUG ? value DIG 2                           ' Show digit 2 (7)

  FOR idx = 0 TO 4
    DEBUG ? value DIG idx                       ' Show digits 0 - 4 of 9742
  NEXT
  END
''   File....... SW21-EX28-ADC0831-Simple-Vref.BS2'   Purpose.... Servo control and positioning with a potentiometer'   Author..... (C) 2000 - 2005, Parallax, Inc.'   E-mail..... support@parallax.com'   Started....'   Updated.... 01 SEP 2005''   {$STAMP BS2}'   {$PBASIC 2.5}
This the part of this code that I have a question about is there a way to change it to this 2 digit 12.00 like this
This code below show with 1 digit it like this 1.200
Main:  DO    GOSUB Read_0831                             ' read the ADC    mVolts = result */ Cnts2Mv                  ' convert to millivolts
    DEBUG HOME,                                 ' report
          CRSRXY, 9, 0, DEC result, CLREOL,
          CRSRXY, 9, 1, DEC mVolts DIG 3,
                        ".", DEC3 mVolts ......>>>>>>>> I try ed to change this line " " to this  1 200 show this way
                                                                    I want to change where the "." point is in the display
                                                                    How do i change it       
     PAUSE 100
LOOP


Sam

I Want  Thank You for All Of Your Time And Help

...............In Helping Getting Thing To Work........

JonnyMac

If you have a word-sized variable and want to display it as x.xx (two digits after the decimal) you can do this with DEBUG

  DEBUG DEC myValue / 100, ".", DEC2 myValue

The DIG operator is not required.
Jon McPhalen
EFX-TEK Hollywood Office