Execute when macro ends

shigomotu

Lifetimer
Joined
Nov 17, 2005
Messages
108
Reaction score
5
Points
18
This may well be a silly question, but is there a way to have a macro execute one last set of commands when it ends?

I thought I stumbled across something a few days ago that suggested this was a possibility using a loop tag similar to :EOM at the end of the main sub. But of course now I can't find it again and trying to decide if I just imagined it.
 
Your looking for :OnExit

Here's a sample macro of how it works I just wrote up and tested.

Code:
Sub Main
:MainLoop
/echo In Main Sub
/delay 2s
/echo Looping MainSub Again
/goto :MainLoop

:OnExit
/echo triggered on Exit by ending macro
/delay 2s
/echo Ending the OnExit, making sure we have a /return or things go to crap and we get stuck in a loop
/return
 
  • Like
Reactions: EQDAB
The

:OnExit
/echo The macro is now exiting
/return


can be outside of all functions as well
Code:
Sub Main
    /while (1) {
        /echo In Main Sub
        /delay 2s
        
    }
/return

:OnExit
    /echo triggered on Exit by ending macro
    /delay 2s
    /echo Ending the OnExit, making sure we have a /return or things go to crap and we get stuck in a loop
    /return

Sub EchoSub
    /echo Looping EchoSub
/return
 
  • Love
Reactions: EQDAB
there is (was) a william12 post that had a down/holy flag that would do something else if the current macro ended, youll have to do a search and see if its still there somewhere
 
  • Like
Reactions: EQDAB