Page 1 of 1

VOTE --- STEP of FOR/NEXT as expression instead #constant !?

Posted: Tue Mar 22, 2005 12:41 am
by Ralf
what do you think about this? would you like to have the feature of variable expressions for STEP value instead only using #constants?

Code: Select all

;---- actual pure version - this works ----

FOR i = 0 TO 1024 STEP 64        
   your code...
NEXT

;---- add this feature / dont work in actual version ----

mystep = 1024/64     <<< STEP can ever be changed !!!

FOR i = 0 TO 1024 STEP mystep
   your code...
NEXT


Posted: Tue Mar 22, 2005 1:51 am
by Hroudtwolf
Thats a really good idea. I know this feature from QB and TurboBasic

Posted: Tue Mar 22, 2005 2:28 am
by dracflamloc
Interesting. I'd like to see it

Posted: Tue Mar 22, 2005 7:10 am
by DarkDragon
And well, I'd like to have floats in the first variable, can you edit your post and add a second question?

Posted: Tue Mar 22, 2005 3:51 pm
by Tranquil
Its allready possible:

Code: Select all

 For N=0 to 2000:N+YourStepValue

Next n
Thats the same way you have to do it in C or C#. So, your suggestion is fine but not realy in need!

Cheers

Posted: Tue Mar 22, 2005 4:50 pm
by Max.
Tranquil wrote:Its allready possible:

Code: Select all

 For N=0 to 2000:N+YourStepValue

Next n
Thats the same way you have to do it in C or C#. So, your suggestion is fine but not realy in need!

Cheers
Maybe I missed something, but I expect using 10 as YourStepValue:

0, 10, 20, 30, ...

and not

11, 22, 33, 44 ...

Posted: Tue Mar 22, 2005 4:55 pm
by Tension
Perhaps because the loop is incrementing the index N by 1 and then yourStepValue is adding another 10?

Posted: Tue Mar 22, 2005 5:05 pm
by Max.
Tension wrote:Perhaps because the loop is incrementing the index N by 1 and then yourStepValue is adding another 10?
Yep. It would work with

Code: Select all

YourStepValue = 10

 For N=0 To 2000-YourStepValue Step 0:N+YourStepValue
  Debug n
Next n 
:twisted:

Posted: Tue Mar 22, 2005 5:08 pm
by Tension
:)

Posted: Tue Mar 22, 2005 11:38 pm
by DoubleDutch
Wouldn't it be better...

Code: Select all

YourStepValue=10
For N=0 to 2000
  Debug N


  N+YourStepValue-1
Next N
This should be more similar to the results in other basics :)

Posted: Thu Mar 24, 2005 12:06 pm
by Ralf
Tranquil wrote:Its allready possible:

Code: Select all

 For N=0 to 2000:N+YourStepValue

Next n
Thats the same way you have to do it in C or C#. So, your suggestion is fine but not realy in need!

Cheers
Mike, in your example you can do user defined steps but if you write it this way, you get wrong results, because you add the YourStepValue before using/work with N inside the loop! So you have to put N-YourStepValue in end of the loop and this way is way known (i dont like this way)!

See DoubleDutch´s example... that would be correct as long as pure dont support it directly with STEP value

Posted: Mon Jun 20, 2005 1:16 pm
by Ralf
Hi Fred!
Will you surprise us with this feature for 3.94 final? :wink: