Going back
BlitzMax Forums/BlitzMax Beginners Area/Going back
| ||
Hi everyone, brand new to Blitzmax so I got a question :). *Note on previous coding experienace - Worked with DarkBasic for about 2 years, never released anything but got pretty good at it. Have been on and off with c++ so very little knowledge of it, just concepts mostly. Here is what I'm basicly attempting to do... (shortened) ========================================== 'graphics stuff bla bla bla while not hitkey() bla bla bla goto stuff bla bla bla flip wend #stuff bla bla bla <--- and here is my question point. How do I tell it to return right after telling it to go here? Have been looking all over the place for a whlie now but have had no success at finding an answer. end ========================================== Anyways thanks in advance for the help. I just began a new setup as I got a mac mini and wanted to program for it. Had been looking at cocoa with Code X, but had suddenly remembered Blitzmax was for Mac so go it :). I'll countinue learning Cocoa with Code X, but looking at a game/graphics rendering perspective, it looks like Blitzmax would be just as powerfull and faster. Anyways thanks for your help again :). |
| ||
In best you don't use goto as it won't work in strict mode. for that kind of things there are functions ... and if you insist on goto: you have to place a label to jump back with goto again. |
| ||
Alright, function would be just as fine. But question remains... would ending the function return it to that spot? And thanks :) |
| ||
Yes it would If you call a function the code runs further from where you called the function, after it ends. |
| ||
Ah, that explains it, thanks again. |
| ||
You can also return early using: Return or return a value using: Return my_var_or_const |
| ||
Return is also good for ending a function prematurely (before it has run its course). |
| ||
Or you can add a label just past where you jumped FROM, that you jump back TO. |
| ||
Don't encourage him. |
| ||
Graphics stuff bla bla bla #main_loop 'indicates a labelled loop While Not KeyHit(bla) bla bla bla Exit main_loop 'exits a labelled loop bla bla bla Flip Wend bla bla bla |