Shop OBEX P1 Docs P2 Docs Learn Events
PropBasic: Default VAR value in sub — Parallax Forums

PropBasic: Default VAR value in sub

VonSzarvasVonSzarvas Posts: 3,525
edited 2010-09-27 09:19 in Propeller 1
In a sub, a VAR defined thus:
timeout    VAR     Long = 100

...will only be "default" set to 100 once (defined globally rather than in the sub)

Thus, if the same sub is called multiple times, the timeout/VAR does not reset each time to default value (100 in this example).

Is this by design?
Should I have already read about this "gotcha" somewhere? - Forgive me if I should have done:)

Might it be better for the compiler to interpret such SUB/FUNC code as:
timeout VAR Long
timeout = 100

?

Not sure, but that might be what the feature intended?
Sign In or Register to comment.