Getting access to the EachIn counter
BlitzMax Forums/BlitzMax Programming/Getting access to the EachIn counter
| ||
Is it possible to get access to and alter the counter value or offset or address or whatever it is, of the EachIn counter? e.g. If I do: For a=EachIn b Print a Next a it's evident that the a object actually points to each instance of the b objects, for each loop iteration. So a isn't a loopcounter, it's an actual object. So the loopcounter is `hidden` and handled behind the scenes. So with that in mind, it isn't possible to do a=5 to jump to offset 5 (ie to backtrack and force the loop to rewind and then continue counting). You can do: For a=0 to 9 Print b[a] If KeyHit(KEY_ESCAPE) Then a=5 Next but you can't do For a=EachIn b print a If KeyHit(KEY_ESCAPE) Then EachIn=5 Next Of course that's not correct syntax. Is there any way to access and modify that counter or is it so hardwired that it's not flexible? I'd like to use the extra speed possibly with EachIn but still modify which object the loop is currently at. |
| ||
I don't think you can, take a look at the collection help (Help->Language->Collections), Eachin uses the methods HasNext:Int() and NextObject:Object() to iterate through them. |
| ||
This might be helpful: http://www.blitzbasic.com/Community/posts.php?topic=50285 |
| ||
Hmm ok well never mind. |
| ||
You could always write this feature into an extended version of the type... |