Variable for/next step workaround?

Just starting out? Need help? Post your questions and find answers here.
Justin
Addict
Addict
Posts: 958
Joined: Sat Apr 26, 2003 2:49 pm

Variable for/next step workaround?

Post 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.
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: Variable for/next step workaround?

Post 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.
Justin
Addict
Addict
Posts: 958
Joined: Sat Apr 26, 2003 2:49 pm

Post by Justin »

Thanks, it works, although it's slower. I hope we can have the variable step soon.
User avatar
tinman
PureBasic Expert
PureBasic Expert
Posts: 1102
Joined: Sat Apr 26, 2003 4:56 pm
Location: Level 5 of Robot Hell
Contact:

Post by tinman »

Code: Select all

x = 1
While x < 100
   ; processing for loop
   x + a
Wend
If you paint your butt blue and glue the hole shut you just themed your ass but lost the functionality.
(WinXPhSP3 PB5.20b14)
Justin
Addict
Addict
Posts: 958
Joined: Sat Apr 26, 2003 2:49 pm

Post by Justin »

Thanks, i'll try that too.
Post Reply