Page 1 of 1 1
Topic Options
#94265 - 2002-10-11 02:37 PM Exit functions with a goto .. possible ?
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Hey all,

on the game I write currently I'd like to be able to break the current running at any point and start over a new game via the options childform ...
This will need a Goto from inside a function to outside a function, Impossible i'm afraid.

Anyone to proof me wrong ?

Jochen
_________________________



Top
#94266 - 2002-10-11 02:39 PM Re: Exit functions with a goto .. possible ?
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
no goto is never actually needed.
goto is just a workaround.

give an example where you would "need" it and others can go around it.
_________________________
!

download KiXnet

Top
#94267 - 2002-10-11 02:45 PM Re: Exit functions with a goto .. possible ?
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
well ,

the game itself is just a do until :

simplified :

code:
:newgame
do
-> function calls
until GameIsOver()

so from inside any function to the options form (no problem) to the beginning of the loop (can't think of other ways than goto !)
_________________________



Top
#94268 - 2002-10-11 03:12 PM Re: Exit functions with a goto .. possible ?
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
HAH !

I could always pack the whole loop into a function and call itself !

Hmmm .. as long as I don't pass variables to itself there shouldn't be any issues

Sometimes the dime drops pennywise , must've get old [Roll Eyes]

J.
_________________________



Top
#94269 - 2002-10-11 03:20 PM Re: Exit functions with a goto .. possible ?
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
well, if you have those serial functions that are executed one after another, you could output break info.
mmm... not as output value but error maybe...

code:
$functions="function1","function2","function3,GameIsOver()"
for $c=0 to ubound($functions)
$=execute($functions[$c])
$error=@error
if $error=22 ;newgame
$c=-1
endif
if $error=33 ;gameover
$c=ubound($functions)
next

_________________________
!

download KiXnet

Top
#94270 - 2002-10-11 03:21 PM Re: Exit functions with a goto .. possible ?
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Could you not just EXIT X with a specific error and then check the erorr?

{edit} gee... how minds think alike...

[ 11. October 2002, 15:22: Message edited by: LLigetfa ]
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#94271 - 2002-10-11 03:22 PM Re: Exit functions with a goto .. possible ?
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
good point les [Roll Eyes]
_________________________
!

download KiXnet

Top
#94272 - 2002-10-11 03:26 PM Re: Exit functions with a goto .. possible ?
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Well Jooel, this time you deserve the credit. Higher golf score and still posted one minute sooner.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#94273 - 2002-10-11 03:34 PM Re: Exit functions with a goto .. possible ?
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
too many checkpoints .. as the bgi version has actually (unfinished) 2600 + lines, the Kixforms version will have approx. 2000 I will stick with the function 'recall' on specific events (such as F2 Key was pressed)

thanx anyway

J.
_________________________



Top
#94274 - 2002-10-11 09:16 PM Re: Exit functions with a goto .. possible ?
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
jochen?
I think there was 1 checkpoint in my script?

how much less you can make it?

well, at least I showed what I wanted.
goto is never needed. it's for ppl who don't want to think too much [Wink]
or are too lazy (like many of the coders are)

[ 11. October 2002, 21:19: Message edited by: Lonkero ]
_________________________
!

download KiXnet

Top
#94275 - 2002-10-12 09:27 AM Re: Exit functions with a goto .. possible ?
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
nested functions is the cause of too many checkpoints ... wait a bit and you'll see (hopefully I can put it under the X-mas tree [Big Grin] )
_________________________



Top
#94276 - 2002-10-12 09:36 AM Re: Exit functions with a goto .. possible ?
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
will see...

 
_________________________
!

download KiXnet

Top
Page 1 of 1 1


Moderator:  Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Allen) and 641 anonymous users online.
Newest Members
fgarcia, Viginette, ManuvdWielNL, Sir_Barrington, batdk82
17889 Registered Users

Generated in 0.062 seconds in which 0.023 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org