Going back

BlitzMax Forums/BlitzMax Beginners Area/Going back

Sakamoto(Posted 2005) [#1]
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 :).


Dreamora(Posted 2005) [#2]
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.


Sakamoto(Posted 2005) [#3]
Alright, function would be just as fine. But question remains... would ending the function return it to that spot?
And thanks :)


Dreamora(Posted 2005) [#4]
Yes it would
If you call a function the code runs further from where you called the function, after it ends.


Sakamoto(Posted 2005) [#5]
Ah, that explains it, thanks again.


Beaker(Posted 2005) [#6]
You can also return early using:
Return

or return a value using:
Return my_var_or_const


FlameDuck(Posted 2005) [#7]
Return is also good for ending a function prematurely (before it has run its course).


ImaginaryHuman(Posted 2005) [#8]
Or you can add a label just past where you jumped FROM, that you jump back TO.


FlameDuck(Posted 2005) [#9]
Don't encourage him.


marksibly(Posted 2005) [#10]
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