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

Everything else that doesn't fall into one of the other PB categories.

Wishlist: STEP of FOR/NEXT as expression instead #constant !?

Yes, i agree to have this feature! Would make things more easy...
31
84%
No, i dont need this feature...
6
16%
I dont know - i dont code :-)
0
No votes
 
Total votes: 37

Ralf
Enthusiast
Enthusiast
Posts: 203
Joined: Fri May 30, 2003 1:29 pm
Location: Germany

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

Post 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

User avatar
Hroudtwolf
Addict
Addict
Posts: 803
Joined: Sat Feb 12, 2005 3:35 am
Location: Germany(Hessen)
Contact:

Post by Hroudtwolf »

Thats a really good idea. I know this feature from QB and TurboBasic
dracflamloc
Addict
Addict
Posts: 1648
Joined: Mon Sep 20, 2004 3:52 pm
Contact:

Post by dracflamloc »

Interesting. I'd like to see it
DarkDragon
Addict
Addict
Posts: 2344
Joined: Mon Jun 02, 2003 9:16 am
Location: Germany
Contact:

Post by DarkDragon »

And well, I'd like to have floats in the first variable, can you edit your post and add a second question?
bye,
Daniel
Tranquil
Addict
Addict
Posts: 952
Joined: Mon Apr 28, 2003 2:22 pm
Location: Europe

Post 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
Tranquil
Max.
Enthusiast
Enthusiast
Posts: 225
Joined: Fri Apr 25, 2003 8:39 pm

Post 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 ...
Athlon64 3800+ · 1 GB RAM · Radeon X800 XL · Win XP Prof/SP1+IE6.0/Firefox · PB 3.94/4.0
Intel Centrino 1.4 MHz · 1.5 GB RAM · Radeon 9000 Mobility · Win XP Prof/SP2+IE6.0/Firefox · PB 3.94/4.0
Tension
User
User
Posts: 29
Joined: Tue Mar 22, 2005 3:19 pm

Post by Tension »

Perhaps because the loop is incrementing the index N by 1 and then yourStepValue is adding another 10?
Max.
Enthusiast
Enthusiast
Posts: 225
Joined: Fri Apr 25, 2003 8:39 pm

Post 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:
Athlon64 3800+ · 1 GB RAM · Radeon X800 XL · Win XP Prof/SP1+IE6.0/Firefox · PB 3.94/4.0
Intel Centrino 1.4 MHz · 1.5 GB RAM · Radeon 9000 Mobility · Win XP Prof/SP2+IE6.0/Firefox · PB 3.94/4.0
Tension
User
User
Posts: 29
Joined: Tue Mar 22, 2005 3:19 pm

Post by Tension »

:)
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Post 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 :)
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
Ralf
Enthusiast
Enthusiast
Posts: 203
Joined: Fri May 30, 2003 1:29 pm
Location: Germany

Post 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
Ralf
Enthusiast
Enthusiast
Posts: 203
Joined: Fri May 30, 2003 1:29 pm
Location: Germany

Post by Ralf »

Hi Fred!
Will you surprise us with this feature for 3.94 final? :wink:
Post Reply