Jump to content
Macro Express Forums

Terminating a macro


Recommended Posts

Is there a way to terminate a macro from within another macro?

 

I have a macro (macro 1) that, as its last item, displays a text box. Control-right clicking on an item in that text box triggers another macro (macro 2), the "Control-right click" being the trigger for that macro. Part of macro 2 includes closing the text box of macro 1, which, being the last item in macro 1, thereby effectively terminates macro 1.

 

When macro 2 is finished with its process, I would like to present an option, asking in essence, "do you want to run macro 1 again?" The only way I know of doing that is by inserting a "Macro Run" command at that point in macro 2. This does go back to running macro 1 again from the beginning, but the problem is that, when that final text box of macro 1 once again appears, the "Control-right click" trigger for macro 2 is now ineffective, as macro 2 will terminate only once macro 1 has terminated.

 

Hm... going around in circles with this one.

Link to comment
Share on other sites

Your process is circuitous and confusing. Too early to comprehend without coffee. I don't think there's a command to terminate another running macro. I suggest you re-think your process. I'm thinking perhaps having another macro controlling the others. Look at the Macro Return command. I could see the controlling macro waiting for the other to complete and optionally having the user to return to it. I don't know. Too early. But that might get you headed in the right direction. 

Link to comment
Share on other sites

Well that's some good left-brain exercise there!  LOL.   Not sure I'm understanding... Also as Cory recommends, reworking your logic flow might be good.  

 

Nevertheless:  I see that there is a Macro Stop command.  If you select it and press F1, you'll get the relevant page in the help file.  There is a note at the bottom that suggests you can put the Macro Stop command in there, and the macro will continue to play to the end...  I'm not sure how that even works, as I have never used the command.  

Link to comment
Share on other sites

10 minutes ago, kunkel321 said:

Well that's some good left-brain exercise there!  LOL.   Not sure I'm understanding... Also as Cory recommends, reworking your logic flow might be good.  

 

Nevertheless:  I see that there is a Macro Stop command.  If you select it and press F1, you'll get the relevant page in the help file.  There is a note at the bottom that suggests you can put the Macro Stop command in there, and the macro will continue to play to the end...  I'm not sure how that even works, as I have never used the command.  

 

Yes, but Macro Stop is effective only for the macro that it is placed in; it cannot terminate another named macro.

 

A lot of this is motivated by the fact  that you cannot create multiple choice text boxes where the items are formatted by font. I want to be able quickly to select different text items whose text might be identical, but whose formatting is different. For instance:

 

Allegro

Allegro

cresc.

cresc.

 

If you put this items into a multiple choice window, they all look the same. So you have to add some flags, like:

 

Allegro <b>

Allegro <bi>

cresc. <r>

cresc. <i>

 

For longer lists, this soon becomes less than obvious. So I decided to pop these text items, formatted, into a text box. This text box is the last item in macro 1.

Ctrl-Right clicking then activates macro 2. This one begins by double clicking on the item I control-right clicked in macro 1, copying that text string, and then closing the open window from macro 1. But I want the option to select more text items. So I need an IF statement to give me that option, of restarting macro 1. That works. But because macro 2 can then not continue, and thus not terminate, until the macro 1, that it called, is then terminated, the "Ctrl-Right click" activation cannot activate macro 2, as it is still active.

 

I have now solved this problem (this is like Monty Python) by creating a text string in macro 2 that modifies a text string by appending "&&THIS IS MY DOG&&" and copying that text string to the clipboard. macro 3 (!!! YES!!!) has as an activation that when the clipboard contains "&&THIS IS MY DOG&&", it executes. This allows macro 2 to terminate, and I can refer back to macro 1 from macro 3. And now, I can "Ctrl-right click" again in my text box of macro 1...

 

I have had to resort to subsidiary macros like that a few times in the past, but have never had to resort to three macros to get the effect that I need.

 

I wish that Macro Express would, at some point, include the possibility to create Multiple Choice windows that display formatted text strings, and that will allow mixing radio buttons and check boxes. I know you can run external scripts (like AutoIT) to effect this, but I am not sufficiently versed in that.

 

Link to comment
Share on other sites

Try some method other than "MacroRun" for Macro2 to start up Macro1 -- for example, by having Macro2 create a file and starting Macro1 based on the Directory Modification trigger.  Or (simpler) start Macro1 when Macro2 places some unique data into the Clipboard.  Either way, the triggering of Macro1 by Macro2 will be asynchronous (I like that word) to whether Macro2 keeps running or not, so you should be able to terminate Macro2 immediately after creating the trigger.  Clipboard trigger seems simpler, as long as it doesn't interfere with other stuff that is going on, either within or outside of Macro Express.   

 

Draw a little flowchart, so when you come back to these macros six months from now, you will remember what the heck you did.  🧐

Link to comment
Share on other sites

1 hour ago, rberq said:

...

Or (simpler) start Macro1 when Macro2 places some unique data into the Clipboard.

...

 

That’s why I append "&&THIS IS MY DOG&&" to the clipboard... I feel relative certain that I will never place that text string to the clipboard from any other source....

 

Anyway... I am actually quite amused at the absurdities of this challenge... but I’m almost there now!

Link to comment
Share on other sites

By the way, if it is of any interest... this turned out to be a major pickle, but I finally worked out all the kinks. For users of a different forum, I created a short video that illustrates how these macros operate.

 

I use Macro Express extensively for working with a 16-bit MS-DOS application, that I run within DosBOX. Believe it or not, there are many people who do this...

 

This video also shows a Macro Express macro that creates alpha-numeric input data from a MIDI input text string. Enjoy...

 

Here is the link:

 

https://youtu.be/FKRO_7hwk6o

Link to comment
Share on other sites

21 hours ago, kunkel321 said:

Wow, very cool!  I'm curious, how many commands are in your 3 scripts?  Looking at your video, it seems like there must be hundreds.  

 

Well... the MIDI input macro at this point is 868 lines of code... that was one of the most fiendishly difficult problems I ever had to solve; lots of sequencing simultaneously different points of the same array and fun stuff like that...  due to the conventions of musical notation, the explicit nature of the MIDI code just cannot be translated directly into music notation code.

 

The "text item entry" routine at this point consists of seven different macros, several of which are triggered by certain events. Total lines of code, in the aggreate, is several hundred, but that also contains a whole catalog of text items defined and referenced internally. But I have been using this now for two days, and it works like a charm.

 

I don’t know why they can’t give us Multiple Choice windows where the choices are "formattable". In essence, I am using a text box as a multiple choice window. This is kind of daft...

Link to comment
Share on other sites

On 5/3/2019 at 9:44 AM, MakaPakaTobyHannah said:

I don’t know why they can’t give us Multiple Choice windows where the choices are "formattable". 

 

You probably have already thought of this...  But have you tried embedding the formatting information in different ways in the multi choice box?   For example with accelerator keys, such as 

Allegr&o

&Allegro

Would appear as 

Allegro

Allegro

But each would appear as just Allegro when it was sent to a variable from the multi choice box.  

 

Also, maybe 

tag1Allegro

tag2Allegro

Then Variable Modify String > Delete part of text after the variable is sent from the multi box.

 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...