Different type of loop

Blitz3D Forums/Blitz3D Programming/Different type of loop

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

but I've learned that they pretty much do the same thing
They don't. They're hugely different.

While... Wend tests the condition at the start of the loop. The loop repeats until the condition is false.

Repeat... Until, tests the condition at the end of the loop - code in the loop will always run at least once.

Repeat... Forever, will.... repeat a loop forever, obviously. To get out of it you must manually call an Exit.

For... Next, executes a loop a specific number of times.

Two things about your original code:

1. It *will* fail with a stack overflow eventually. Your function is calling itself repeatedly and it is not possible for the function to exit and remove the pointer from the stack.

2. There is no point in checking that many values with KeyDown. KeyDown uses scancodes, not ASCII codes. Much better to just check the ones you want.

[edit] what on God's earth is that code above meant to prove? Your For/Next loop will obviously be quicker as you aren't doing anything in it like you are with the others.