Macro
From ArcoWiki
								Macro are sub-routines that allow to compact a sequence of instructions in a single command.
The macro command can be in the main program or in an external file.
If the macro commands are in the program, they have to be written at the beginning of it.
$$ Example of a MACRO declaration
- M(foro)=MACRO/off_x,off_y,'nome_ci'- DECL/LOCAL,DOUBLE,r_foro,z_mis
- r_foro=ASSIGN/6.25
- z_mis=ASSIGN/-2.5
- F(@nome_ci) = FEAT/CIRCLE, INNER, CART, off_x, off_y, z_mis, 0, 0, 1, r_foro*2
- MEAS/CIRCLE, F(@nome_ci), 4
- GOTO/off_x, off_y, 7
- PTMEAS/CART, off_x+r_foro, off_y, z_mis, -1, 0, 0
- PTMEAS/CART, off_x, off_y+r_foro, z_mis, 0, -1, 0
- PTMEAS/CART, off_x-r_foro, off_y, z_mis, 1, 0, 0
- PTMEAS/CART, off_x, off_y-r_foro, z_mis, 0, 1, 0
- GOTO/off_x, off_y, 7
- ENDMES
- $$ End of Macro Declaration
 
 
- ENDMAC
 
- $$ instructions
- $$ instructions
 
$$ Recall to execute the macro
- CALL/M(foro),12.5,12.5,(foro1)
 
- $$ instructions
- $$ instructions
 
Using the ‘EXTFIL’ command, tha macros are recalled from the specified external file.
$$ Use of an external file containing macro declaration
- EXTFIL/DMIS,'c:\cim\MACRO.dmi'
 
The external macro file has “.DML” extension, begins with DMISMD/ and ends with ENDFIL/.
Inside of the file, the syntax is the same as a regular DMIS program.
$$ Declaration of different Macro in an external file
DMISMD/'module_name'
- $$ First Macro declaration
- M(macro_1)=MACRO/passedtext- TEXT/OPER,CONCAT('You passed the following text to the macro: ',passedtext)
 
 
- ENDMAC
- $$ Second Macro declaration
- M(macro_2)=MACRO/num1,num2- DECL/DOUBLE,sumres
- sumres=ASSIGN/num1+num2
- EXT/OPER,CONCAT('The sum of the 2 numbers is: ',STR(sumres))
 
 
- ENDMAC
 
ENDFIL
