Page 1 of 1

Variable for/next step workaround?

Posted: Sun Jun 15, 2003 2:47 pm
by Justin
Is there any workaround to do something like this?

procedure draw(a)
for x=0 to 100 step a
:
:
next
endprocedure

i need this to do some variable drawing, a pity PB does not support it, maybe in asm?, any idea?, thanks.

Re: Variable for/next step workaround?

Posted: Sun Jun 15, 2003 3:00 pm
by PB
This works:

Code: Select all

Procedure Numbers(a)
  For x=1 To 100
    x+a-1 ; Simulates "Step a"
    Debug x
  Next
EndProcedure
;
Numbers(1) ; Shows 1, 2, 3, 4, 5, etc.
Numbers(5) ; Shows 5, 10, 15, 20, etc.

Posted: Sun Jun 15, 2003 3:46 pm
by Justin
Thanks, it works, although it's slower. I hope we can have the variable step soon.

Posted: Sun Jun 15, 2003 4:25 pm
by tinman

Code: Select all

x = 1
While x < 100
   ; processing for loop
   x + a
Wend

Posted: Sun Jun 15, 2003 10:08 pm
by Justin
Thanks, i'll try that too.