Restarting

Need some help with that macro you're working on or aren't quite sure how to get your macro to do something? Ask here!

Moderator: MacroQuest Developers

hide
decaying skeleton
decaying skeleton
Posts: 1
Joined: Sat Feb 14, 2004 7:09 am

Restarting

Post by hide » Mon Mar 08, 2004 3:18 am

This may be a stupid question, but is there a way to restart a macro from within a sub? If certain conditions occur, I want to restart the macro from the begining and not continue on the current loop. The problem is that the check is nested several layers down in subs.

I think it is illegal to /goto outside the current sub so I cannot just /goto :BEGIN where :BEGIN is the Main Sub.

Take the folloing example:

Code: Select all

 Sub Main
:BEGIN
/call checkok

/call otherstuff
/goto :BEGIN
/return

Sub checkok
 /if <condition> /call restart
/return

Sub restart
???????
/return
What should go into the restart sub?

Also, I know with this simple example, you could just use a return from the checkok sub, but in my real macros check ok is used all over the place and is called from subs nested down several levels.
Last edited by hide on Mon Mar 08, 2004 5:36 am, edited 1 time in total.

Falco72
a hill giant
a hill giant
Posts: 215
Joined: Fri Sep 26, 2003 3:24 am

Post by Falco72 » Mon Mar 08, 2004 4:19 am

I suggest you something like this:

Code: Select all

Sub Main
:startloop
/call whatever
/call some else
/delay 10
/goto :startloop
/return
It will loop the macro till you will not kill it. The /delay command is to not take too many resources of the cpu, no need to have a macro that loop 100 times in a secs.

daerck
a ghoul
a ghoul
Posts: 134
Joined: Mon Jan 12, 2004 8:44 pm

Post by daerck » Mon Mar 08, 2004 9:12 am

You could use the $return and a basic loop, or just incorporate your restart statements in the Main routine.

i.e.

Code: Select all

Sub Main
:Begin
/call checkok
/if $return==RESTART /goto :Begin
{blabla}
/return

Sub checkok
/if condition /return RESTART
/else /return OK