Solved

Automate MUMPS Console commands

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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Backup Data/Portable NAS storage 4 94
Transferring files to iPhone 3 83
Application Crash 2 34
deprecated mysql extensions 1 22
I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
Video by: Tony
This video teaches viewers how to export a project from Adobe Premiere Pro and the various file types involved.
XMind Plus helps organize all details/aspects of any project from large to small in an orderly and concise manner. If you are working on a complex project, use this micro tutorial to show you how to make a basic flow chart. The software is free when…

685 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