A MIDAS command procedure may be created with an editor or via the command
WRITE/COMMANDS which constructs a MIDAS procedure from the current
command buffer. Default type for such a procedure file is .prg .
This MIDAS procedure can then be executed with the commands:
@ file par1 par2 ... par8 ! if the procedure is in MID_PROCwhere par1 ... par8 are the actual parameters which may be accessed within the command procedure through the character keywords P1 ... P8.
@@ file par1 par2 ... par8 ! if in current directory or MID_WORK
@a file par1 par2 ... par8 ! if in APP_PROC
@s file par1 par2 ... par8 ! if in STD_PROC
@c file par1 par2 ... par8 ! if in CON_PROC
!+Entering the MIDAS command @@ exa1 OUTPUTC ESO-Garching will lead to the execution of:
! Example 1, MIDAS procedure exa1.prg
!+
READ/KEYWORD P1 ! read keyword the name of which is given as par1
@@ test P2 ! execute test.prg and pass par2 as first parameter
WRITE/KEYWORD INPUTC P2 ! write contents of par2 into keyword INPUTC
/KEYWORD OUTPUTC
@@ test ESO-Garching
WRITE/KEYWORD INPUTC ESO-Garching
Noteto MIDAS release 88NOV apostrophes were used for symbol substitutions (e.g. 'P1'). Because of the backward compatibility of MIDAS you could still use apostrophes to indicate symbol substitutions, which is, however, discouraged. The main reason being that using and instead, makes nesting of substitutions possible.
!+The MIDAS command: @@ exa2 77 will set INPUTI(7) to 77, whereas @@ exa2 will set INPUTI(7) to 999.
! Example 2, MIDAS procedure exa2.prg
!+
DEFINE/PARAM P1 999 NUMBER "Enter first input number:" 22,1024
DEFINE/MAXPAR 1 ! only 1 parameter expected
WRITE/KEYWORD INPUTI/I/7/1 P1 ! store contents of P1 in INPUTI(7)
!+then @@ exa3 KB will not yield any error.
! Example 3, MIDAS procedure exa3.prg
!+
DEFINE/PARAM P1 999 N/CONT "Enter first input number:"
DEFINE/MAXPAR 1 ! only 1 parameter expected
IF PARSTAT(1) .EQ. 1 -
WRITE/KEYWORD INPUTI/I/7/1 P1 !store contents of P1 in INPUTI(7)
Notecommand CROSSREF has to be the first executable command (i.e. any command but a comment line) in a MIDAS procedure!
The command DEFINE/MAXPAR provides an additional consistency check and helps to detect erroneous usage of MIDAS procedures. Therefore, it's highly recommended to include it in all procedures.
!+then the following command lines will all be equivalent:
! Example 4, MIDAS procedure exa4.prg
!+
CROSSREF IN_FILE OUT_FILE METHOD ALPHA
DEFINE/PARAM P1 ? IMA "Enter name of input file: "
DEFINE/PARAM P2 ? IMA "Enter name of result file: "
DEFINE/PARAM P3 ? C "Enter method: "
DEFINE/PARAM P4 999 NUM "Enter alpha value: " 22,1024
DEFINE/MAXPAR 4 ! max. 4 parameters expected
WRITE/KEYWORD INPUTI/I/7/1 P4
@@ exa4 in out FILTER 33
@@ exa4 P2=out P1=in P4=33 P3=FILTER
@@ exa4 OUT_FILE=out IN_FILE=in alpha=33 METHOD=FILTER
@@ exa4 OUT=out IN_F=in al=33 METH=FILTERis o.k.
!+
! Example 5, MIDAS procedure exa5.prg
!+
CROSSREF IN_FILE OUT_FILE
DEFINE/PARAM P1 ? IMA "Enter name of input file: "
DEFINE/PARAM P2 ? IMA "Enter name of result file: "
DEFINE/MAXPAR 2 ! max. 2 parameters expected
WRITE/KEYWORD IN_B " " all ! fill keyword IN_B with blanks
INQUIRE/KEYWORD IN_B "Which filter, enter LOW or HIGH: "
IF AUX_MODE(7) .EQ. 0 IN_B = "LOW" ! LOW is the default