bb3d feature request

Blitz3D Forums/Blitz3D Programming/bb3d feature request

Picklesworth(Posted 2004) [#1]
This would be a useful feature in blitz. The ability to use And in a For loop. This way, instead of writing

b = 0
For i = 0 To 5
 ;Blah
b = b + 1
next


I could write

For i = 0 To 5 And b = 0 To 5
 ;Blah
Next



koekjesbaby(Posted 2004) [#2]
eh, in your first example b would always be 1


Picklesworth(Posted 2004) [#3]
oh yah, thanks.


Perturbatio(Posted 2004) [#4]
exactly how would this work?

0-5 for each of them fair enough, but how would this work:
for i = 0 to 9 and b = 0 to 4
;blah
Next



AntonyWells(Posted 2004) [#5]
And so ended another american dream.


Bot Builder(Posted 2004) [#6]
:D and what's the difference between that and:

For i = 0 To 5
 b=i
 ;Blah
Next


Less keystrokes anyway if you're looking at it from a C point of view

[edit]Maybe he means it would be like this to the compiler:
For i = 0 To 5
 For b = 0 To 5
  ;Blah
 Next
Next



slenkar(Posted 2004) [#7]
unger baby


Perturbatio(Posted 2004) [#8]


[edit]Maybe he means it would be like this to the compiler:

For i = 0 To 5
For b = 0 To 5
;Blah
Next
Next



Except that wouldn't really save anything at all, except maybe a tab.


N(Posted 2004) [#9]
Well, I could see the equivalent of this happening:

For N = 0 To 8 And B = 5 To 7
Next
[code]

Sortof like this:
[code]
NStart# = 0 : NEnd# = 8 : NDelta# = NEnd#-NStart#
BStart# = 5 : BEnd# = 7 : BDelta# = BEnd#-BStart#

For N# = NStart To NEnd
  B# = BStart+(N# / NDelta#)*BDelta#
Next


Pseudo-code, really, but I think it works in general. In any case, I disagree with this feature request. It's illogical, in my opinion.


Picklesworth(Posted 2004) [#10]
I did my example wrong... The idea would be to have two numbers, both starting at different values, and adding the Step value to themselves every loop. So, you could have

For a = 0 To 5 And b = 5 To 10

Next

To prevent screwups, perhaps a Start operator could be used instead of the two seperate variables.

For a = 0 To 5 And b Start 5

Anyway, it's just a crazy idea. There's some pretty good reasons why not to do it, but it could be kind of useful now that I've clarified my idea.


Bot Builder(Posted 2004) [#11]
Ummm...?
For a=0 To 5
 b=a+5
Next



Picklesworth(Posted 2004) [#12]
bah fine.


N(Posted 2004) [#13]
I've clarified my idea.


Not too well, though. Present a situation where this would actually be useful.


Picklesworth(Posted 2004) [#14]
Uhm, once again, I'm going to clarify.

For t.type = each type And numberTypes = Start 0
;blah
Next

This way, it could count type instances...
I have realised how utterly useless this can be on most occasions, so

Gah, Fine, it looks like you're right again.
I'll just back away, burn the evidence of this post, and hide in my room for a few weeks.


Bot Builder(Posted 2004) [#15]
:P Well at least that one is remorlty useful


N(Posted 2004) [#16]
For t.type = each type And numberTypes = Start 0
;blah
Next 


One line more:

For t.type = each type
   numberTypes = numberTypes + 1
   ;blah
Next


I don't think you really thought your request through at first- just came up with some slightly-interesting idea and posted it.


Picklesworth(Posted 2004) [#17]
just came up with some slightly-interesting idea and posted it.

Hehe, yep. It seemed useful at the time though, maybe I forgot something. Please stop adding replies to this before I go crazy with embarassment :D