• You've discovered RedGuides 📕 an EverQuest multi-boxing community 🛡️🧙🗡️. We want you to play several EQ characters at once, come join us and say hello! 👋
  • IS THIS SITE UGLY? Change the look. To dismiss this notice, click the X --->

Question - Calling a macro within a macro (1 Viewer)

notaplayer

Member
Joined
Jan 2, 2017
RedCents
69¢
I'm new to macro writing, but not "completely" new to coding. Can you call a macro within a subroutine, preferably for a specified period of time, then end it?
 
I'm new to macro writing, but not "completely" new to coding. Can you call a macro within a subroutine, preferably for a specified period of time, then end it?
if you have a macro start another macro, the first macro would end and the new one begin

what you can do is have an include file (.inc) which you can include in your main macro to then call the subs from that include
 
You should avoid running a macro from another macro in most situations, using an .inc file or just adding the needed routines to you current macro. Especially if you go back and forth between the first and second macro.

The only time I use/used a macro to run another macro is for things like a launcher macro, where a single macro when ran will automatically run a variety of macros depending on the class you ran the macro on
 
As sic said, if I did the /timed 60 /mac newmacro, it would end the called macro after 60 seconds/minutes, but also discontinue the original macro also. Correct?
if you did /timed 60 /mac newmacro it would end the macro that is running by default. you would need to put /end after that to to end the current macro so the new one didn't try to start while the old one was still running.
 
To be sure you can only run 1 macro at a time. If you issue a /mac somemacname when you already have a macro running, the macro that is running will end. However, unless it's been corrected since I last checked, calling a macro from another macro will cause the new macro to skip the first line of the second macro. In which if the first line is to create a variable, check a parameter, etc it wouldn't do that action. Typically I just added a /squelch /echo first line could be skipped if this is called from another macro

Additionally, it's not ideal to jump back and forth from one macro to another macro. It's best to combine the two macros so that you can use the other macro without ending the existing macro and going back and forth. Alternately, using an include file will allow you to separate their logic, but still use them both as a single macro.

Example.

INI:
|MacroOne

Sub Main
    /declare something string local MacroOne
    /echo ${something}
    /mac MacroTwo
/return

|MacroTwo
Sub Main
    /declare somethingelse string local MacroTwo
    /echo ${somethingelse}
    /mac MacroOne
/return


Now unless the issue has been corrected, when you call MacroTwo from MacroOne, the declare gets skipped, the echo outputs "NULL" (Will pause for undeclared variable if you add #warning to the top of the macros.) then will call back MacroOne, which would subsequently also repeat the same unexpected behavior.

INI:
|MacroOne

Sub Main
    /squelch /echo first line could be skipped if this is called from another macro
    /declare something string local MacroOne
    /echo ${something}
    /mac MacroTwo
/return

|MacroTwo
Sub Main
    /squelch /echo first line could be skipped if this is called from another macro
    /declare somethingelse string local MacroTwo
    /echo ${somethingelse}
    /mac MacroOne
/return

This method above will add an echo which is called with /squelch

/squelch means to prevent output of text from the command to the MQ2 Chat window. But it gives the macro a line to process at start that can both be invisible when called independently (IE: /mac MacroOne when no macro is already running), and called from another macro would have a line the parser would skip.

As mentioned by others, you can also use a /timed ## /mac MacroTwo where the number symbols represent the amount of time in 10ths of a second you want to wait prior to executing the command. But this is a rather inefficient manner of accomplishing this task. 6 seconds is a rather long time to wait for something else to happen. So by combining the two macros you would simply just call the starting function of the second macro and the transition would be seamless, you avoid bypassing any glitches created by using a method of calling a macro from another macro.

Keep in mind when combining two macros that only one "Sub Main" can exist. otherwise which one to use when a /call is made would be ambiguous. You can rename the starting function of one of the macros from Sub Main to anything else of your choosing.

INI:
|TheOnlyMacro

Sub Main
    /while (1) {
        /declare something string local MacroOne
        /echo ${something}
        /call StepTwo
        |This delay is needed for a while loop. 1/10th of a second is really short so this macro will definitely spam your MQ2 Chat window rather quickly.
        /delay 1
    }
/return

Sub StepTwo
    /declare somethingelse string local MacroTwo
    /echo ${somethingelse}
/return

Something of note when combining two macros is that you cannot have global variable names that are named the same.

globals are the ones that are created using /declare something string outer

where you create a variable named "something" of the type "string" and give it a scope of "outer"

If both macros have variables with the same name then one will need to be renamed throughout it's code to avoid a conflict.
 
Question - Calling a macro within a macro

Users who are viewing this thread

Back
Top