MiniM. Saving time.


| About | Download | Tools | Knowledge Base | How to Buy |

MiniM Overview

Getting Started

Download

Documentation

Tools

Cache Tools

GT.M Tools

Knowledge Base

FAQ

Contacts

Copyrights

MiniM Knowledge Base | Mar 23, 2011

How to Create MiniM Shell Script in MUMPS

MiniM Database Server can be used to execute external automation scripts stored in ordinal text file on the disks. Here we describe how to create shell scripts written in MUMPS language.

To call script file from the Windows shell it is need to register file extension and assign to this extension script handler. For scripts with MUMPS language we will use a .mumps extension. As script handler we will use command file mshell.cmd and store its in the \bin subdirectory of the MiniM installation.

Next all examples assumes that MiniM Database Server was installed in the w:\MiniM directory.

To assosiate file extension and extension handler we must create some Registry records. Example how it can be done, in Windows Registry files notation:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\.mumps]
@="MUMPS Script"

[HKEY_CLASSES_ROOT\MUMPS Script\DefaultIcon]
@="W:\\MiniM\\bin\\minim.exe,0"

[HKEY_CLASSES_ROOT\MUMPS Script\Shell\Open\Command]
@="\"w:\\MiniM\\bin\\mshell.cmd\" \"%1\" %*"

Assosiated file handler must run MiniM process and pass parameters:

@echo off
w:\minim\bin\minim.exe -x 
  "d RUN^%%MSHELL(\"%1\",\"%2\",\"%3\",\"%4\",\"%5\",
    \"%6\",\"%7\",\"%8\",\"%9\")" -h

Here we run our special routine ^%MSHELL which must prepare the following actions:

  • Passed name of the script file use to read this file and create temporary routine with
  • Temporary routine must have name derived from special prefix and use suffix derived from current job number to prevent routine wasting for two or more scripts
  • Temporary routine must be compiled to executable bytecode
  • Temporary bytecode must be executed
  • After routine terminates, temporary routine and bytecode must be removed

All this actions are done by this routine:

%MSHELL
%MSHELL ; MiniM MUMPS Shell scripts
 q
RUN(%fname,%param...)
 n %rname="MSHELL"_$j,%n,%line
 n %dev="|FILE|"_%fname,%eof=$v("proc",5,0)
 k ^rMAC(%rname)
 o %dev:("rt") u %dev
 s %n=1 f  r %line q:$zeof  d
 . s ^rMAC(%rname,%n)=%line
 . s %n=%n+1
 u 0 c %dev
 i $v("proc",5,%eof)
 i '$$COMP^%MPP(%rname) g err
 i $v("rou","c",%rname) g err
 d @("^"_%rname)
 k ^rMAC(%rname),^ROUTINE(%rname),^rOBJ(%rname)
 q
err
 w !,"Failed to compile script file",!,%fname,!
 r "Press any key to remove this routine and terminate.",!,*%n
 k ^rMAC(%rname),^ROUTINE(%rname),^rOBJ(%rname)
 q

After full setup we can create ordinal text files in any directory with the .mumps extension and run they as other script files or executables and pass parameters.

Inside the script file with the MUMPS language we can use macroses, subroutines, dotted syntax as in ordinal macro routines of the MiniM Database Server.

Execution of the .mumps scripts starts from the first line of code and continues until the quit command or the halt command. Script can use all MiniM Database Server possibilities. Process will be run in the default database, specified in the MiniM configuration file minim.ini as a default database for process, section [Process], key Namespace.

While script executes, all script parameters as accessible as subscripted local variable %param, for example if we run script with options

run.mumps option1 option2 

local variable %param have the values:

%param=8
%param(1)="option1"
%param(2)="option2"
%param(3)=""
%param(4)=""
%param(5)=""
%param(6)=""
%param(7)=""
%param(8)=""

Download MiniM Shell Scripts source code (zip, 3Kb)

Download MiniM Shell Scripts installer (exe, 290 Kb)

Eugene Karataev
support@minimdb.com


Copyright (C) Eugene Karataev
Info Support