Solved

Automate MUMPS Console commands

Posted on 2007-03-17
4
895 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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Let’s list some of the technologies that enable smooth teleworking. 
Healthcare organizations in the United States must adhere to the guidance of both the HIPAA (Health Insurance Portability and Accountability Act) and HITECH (Health Information Technology for Economic and Clinical Health Act) for securing and protec…
This video will demonstrate how to find the puppet warp tool from the edit menu and where to put the points to edit.
Using Adobe Premiere Pro, the viewer will learn how to set up a sequence with proper settings, importing pictures, rendering, and exporting the finished product.

773 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