Solved

Automate MUMPS Console commands

Posted on 2007-03-17
4
892 Views
Last Modified: 2013-11-15
I am looking for a way to process multiple MUMPS commands within MSM.EXE to perform a task. I have currently had to repeatedly type the same commands into the MSM.EXE console over and over, and would like to automate this process. It would also be useful if I could pass in custom variables into the console, such as paths, which may occasionally change when the solution is used on different host environments. I appreaciate this may not be possible but it would be a nice to have.

I am a complete novice to MUMPS and am sure there is probably an easy solution to what I ask?

Thanks in advance,

Ben
0
Comment
Question by:Benjamin297
  • 2
4 Comments
 
LVL 25

Accepted Solution

by:
clockwatcher earned 500 total points
ID: 18784234
What exactly do you mean when you say you have to type multiple commands into the console?  What commands are you typing in?  Why not put them in a routine and execute the routine?

I don't have an old copy of MSM around but I believe you should be able to create a routine with:

>ZREMOVE
>MYROUT     ; enter the commands you use below
>     D ^something
>     D ^anotherthing
>     W "I'm done",!
>ZSAVE MYROUT
>

Replace the five spaces above with a TAB.   If you can't create a routine directly from the console, then I think

>X ^%

or

>X ^%G

should get you an editor that you can use to create the routine.  If I had an old copy around, I could be of more help.  I haven't been on a dos-based MSM system in about 7 years and the only thing I can find now is MSM workstation which is different.

Once you've got your routine saved.   Execute it with

>D ^MYROUT

As for different host environments and variables, you'd probably want to set your variables in globals and then reference them in your code.

>SET ^PATH="c:\somewhere\on\this\machine.txt"
>DO ^MYROUT

where MYROUT looks like:

MYROUT  ;
     WRITE ^PATH
     D SOMETHING^WITH(^PATH)
     Q
0
 
LVL 1

Expert Comment

by:LarryAndro
ID: 18857707
You should check out AutoHotKey, a macro program that is very powerful!  It might better be called a programming languange.  www.autohotkey.com.
0
 
LVL 1

Expert Comment

by:LarryAndro
ID: 19124751
One additional suggestion as to editing M routines: do it in an ASCII text editor like UltraEdit.  I think Notepad will work also.  MS Word would work, but it inserts too many auto-corrections that trip you up, unless you've turned off the offending auto-corrections.  Any text editor that stores ASCII text, and leaves a tab stored as a tab, should work.  

Using a text editor is much better than X ^%, etc, as they are full-screen editors you already know how to use, offer much better ability to copy/cut/move, etc that the bare-bones editors in MSM!

But, creating the code is one thing.  How to move it into M?  Here are the steps...

* Copy the M code in the text editor to clipboard.
* Enter 'ZR<return>' at the programmer's prompt in MSM.
* Paste clipboard.
* Enter 'ZS routineName<return>'

The first few times you do the above, I recommend saving the code in a scratch routine name.  Almost always the pasted text technique works quite well, not dropping characters no matter how long the routine is.  But, on an occasional system, this technique doesn't work.

To carry this technique further, you can always calculate rudimentary checksums to verify the process works OK.  If interested, let me know, and I will paste in here a line or two of M code that will calculate checksums for M routines.

Hope this makes sense.
0
 

Expert Comment

by:xavis67
ID: 21254847
in background use:

JOB ^MYROUTINE
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
URL to download Windows 10 Home 2 134
Open Source: Multi-Level-Marketing software? 3 131
Magic Software info 18 125
Q-See QT View from the Apple Store or ..,.. ? 2 91
Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
Developer portfolios can be a bit of an enigma—how do you present yourself to employers without burying them in lines of code?  A modern portfolio is more than just work samples, it’s also a statement of how you work.
This video shows how use content aware, what it’s used for, and when to use it over other tools.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now