Shop OBEX P1 Docs P2 Docs Learn Events
Flat Spin — Parallax Forums

Flat Spin

codemonkeycodemonkey Posts: 38
edited 2007-05-27 16:47 in Propeller 1
I've run into the situation where setting a byte in an array to zero seems to clear out
the index. I've been beating my head way too long. What am i doing wrong? I
can't get it to happen when i try to isolate it, but i've included the pertinent code
here.

(The lines that have <== on them are extra statements to work around the problem;
the <== doesn't actually appear in the real code, just this post. The one "offending"
line of code has an uppercase comment just for this post)


Dat
ThirteenString byte (13)
gActiveSpeed long·
<snip>
· speedCalc(gActiveSpeed, 1, @ThirteenString)
<snip>

PUB speedCalc(speed, decplaces, xere) | i, j, m
<snip>·<== up until this point, evocations of i++ and xere[noparse][[/noparse]i++] work just fine
· m := i <==
· xere[noparse][[/noparse]i++] := 0· 'Terminating null <== THIS STATEMENT SETS i TO 0
· i := m <==
· i++ <==
<snip> <= and after this point, no problems

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-05-27 04:38
    The "speedCalc" routine is working the way you defined it. You've got a parameter "xere" followed by a local variable "i". Both are simple LONG variables (not arrays). "i" is probably 1 at the statement that sets "i" to 0. "xere[noparse][[/noparse] i++ ]" references the variable that follows "xere" which is "i" and it gets set to zero. What you want to use is "BYTE[noparse][[/noparse] xere ][noparse][[/noparse] i++ ]".
  • codemonkeycodemonkey Posts: 38
    edited 2007-05-27 16:47
    Thanks Mike, I'm sure the byte thingie is what i want. I never would have expected the current behavior. Just when you think you've got the thing under control, WHAP!
Sign In or Register to comment.