TIP: Flexible parameterization of MATRIX Macros.

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

TIP: Flexible parameterization of MATRIX Macros.

David Marso
Administrator
This post was updated on .
CONTEXT: I recently encountered a situation where I desired to make the input to a MATRIX MACRO a bit more flexible.  

Iteration 1 was to feed the macro a matrix in the format expected by MATRIX (elements in a row separated by , columns delimited by ; ).  
It came to pass that in a CD textbox that a matrix input was a PIA WRT verifiability
(possibly long input, CD TB is short (GRID implementation PLEASE)).

SOLUTION:  feed it a dataset name!

IMPLEMENTATION:

DEFINE FlexParam ( x !CMDEND)
!IF (!INDEX(!x,",") !EQ 0) !THEN
DATASET ACTIVATE !X .
!IFEND
MATRIX.
!IF (!INDEX(!x,",") !EQ 0) !THEN
GET X / FILE * .
!ELSE
COMPUTE X={!x}.
!IFEND
PRINT X.
END MATRIX.
!ENDDEFINE.

DATA LIST FREE / x1 to x4.
BEGIN DATA
1 2 3 4
5 6 7 8
END DATA.
DATASET NAME xParam.

FlexParam x=1,2,3,4;
            5,6,7,8 .
FlexParam x=xParam .

OUTPUT:
 
FlexParam x=1,2,3,4;
            5,6,7,8 .

Run MATRIX procedure:
 
X
  1  2  3  4
  5  6  7  8
 
------ END MATRIX -----

FlexParam x=xParam .

Run MATRIX procedure:
 
X
  1  2  3  4
  5  6  7  8
 
------ END MATRIX -----

ENJOY!
Comments?

Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"