Shop OBEX P1 Docs P2 Docs Learn Events
BYTE[Offset] — Parallax Forums

BYTE[Offset]

William50William50 Posts: 22
edited 2008-06-11 18:38 in Propeller 1
Using the code below, will [noparse][[/noparse]Index++] wrap-around to zero when the repeat loop executes the 102nd loop?


Byte Array[noparse][[/noparse]100]
Byte Temp

Index := 0

repeat
Temp := Array[noparse][[/noparse]Index++]

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-06-11 00:30
    No it will not wrap around.· It will continue to increment and, first, you will access Temp since it follows Array in memory, then you will access whatever follows Temp in memory, etc.

    Temp is effectively Array[noparse][[/noparse] 100 ] since array subscripts start at zero.· The memory location beyond Temp is effectively Array[noparse][[/noparse] 101 ].
  • Paul BakerPaul Baker Posts: 6,351
    edited 2008-06-11 18:38
    This will cause it to wrap around:

    Byte Array[noparse][[/noparse]100]
    Byte Temp

    Index := 0

    repeat
    ·Temp := Array[noparse][[/noparse]Index++]
    ·Index //= 100

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
Sign In or Register to comment.