Shop OBEX P1 Docs P2 Docs Learn Events
THE FOR statement — Parallax Forums

THE FOR statement

RobbanRobban Posts: 124
edited 2008-03-03 12:48 in BASIC Stamp
Hi!

I was wondering why i only get the first value of a value...

Like

value var word
i var byte


Value=192
for i=1 to 3
debug dec value(i),cr
next


when i start this program i only get..
1
0
0

i want to get
1
9
2

/why?
Regards
Robban

Comments

  • stamptrolstamptrol Posts: 1,731
    edited 2008-03-03 12:48
    Robban,

    You're trying to read an array which hasn't been properly defined.

    However, the following bit of code from the HELP file will do what you want:

    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

    Cheers,

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tom Sisk

    http://www.siskconsult.com
    ·
Sign In or Register to comment.