Solved

Automate MUMPS Console commands

Posted on 2007-03-17
4
890 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
in background use:

JOB ^MYROUTINE
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Article by: Rob
Notes 8.5 Archiving Steps and Tips This article covers setting up a Notes archive, and helps understand some of the menu choices making setting up and maintaining a Notes archive file easier.
Let’s list some of the technologies that enable smooth teleworking. 
This video demonstrates basic masking and how to edit the mask to reveal the desired image.
The viewer will learn how to create multiple layers to apply various filters and how to delete areas from each layer’s filter.

743 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

14 Experts available now in Live!

Get 1:1 Help Now