Difference between revisions of "Passing Variables And Features To A Macro"
m (1 revision imported) |
|||
(One intermediate revision by one other user not shown) | |||
Line 1: | Line 1: | ||
− | When a [[Macro]] is created, it can receive from the [[DMIS]] program both '''Variables and Features''' as argument.<br /> | + | When a [[Macro]] is created, it can receive from the [[DMIS]] program both '''[[Variables]] and Features''' as argument.<br /> |
== Passing Variable to A Macro == | == Passing Variable to A Macro == | ||
Line 79: | Line 79: | ||
<code>CALL/M(PASSING_A_FEATURE),(P1),'P2',100</code> | <code>CALL/M(PASSING_A_FEATURE),(P1),'P2',100</code> | ||
+ | |||
+ | |||
+ | [[it:Passaggio di variabili e funzionalità a una macro]] | ||
+ | [[zh-cn:将变量和特征传递给宏]] | ||
+ | [[pt:Passando variáveis e recursos para uma macro]] | ||
+ | [[de:Übergeben von Variablen und Features an ein Makro]] | ||
+ | [[es:Pasar variables y características a una macro]] | ||
+ | [[en:Passing Variables And Features To A Macro]] | ||
[[Category:Dmis_Tutorial]] | [[Category:Dmis_Tutorial]] |
Latest revision as of 08:41, 14 June 2018
When a Macro is created, it can receive from the DMIS program both Variables and Features as argument.
Contents
Passing Variable to A Macro
In order to pass a variable to a Macro it is necessary to define in the macro declaration that the argument is a variable:
$$ Example of a MACRO Used with Variable
M(PASSING_A_VARIABLE)=MACRO/MYVARIABLE
DECL/LOCAL,CHAR,128,tmpString
tmpString=ASSIGN/CONCAT('The Variable Passed is: ',STR(MYVARIABLE))
TEXT/OPER,tmpString
ENDMAC
DECL/DOUBLE,PASSED_TO_MACRO
PASSED_TO_MACRO=ASSIGN/100
CALL/M(PASSING_A_VARIABLE),100
CALL/M(PASSING_A_VARIABLE),PASSED_TO_MACRO
Passing Feature to A Macro
In order to pass a featureto a Macro it is necessary to define in the macro declaration that the argument is a feature using the "'" in the declaration and, when calling the Macro, use the "(" and ")" to inform that the feature has been passed.
In the Macro the feature is passed as object, so it can be access directly.
$$ Example of a MACRO Used with Feature passed directly
F(P1)=FEAT/POINT,CART,0,0,0,0,0,1
M(PASSING_A_FEATURE)=MACRO/'FEATURE'
DECL/LOCAL,DOUBLE, XX
XX=OBTAIN/F(FEATURE),3
tmpString=ASSIGN/CONCAT('The X VALUE OF THE PASSED POINT IS: ',STR(XX))
TEXT/OPER,tmpString
ENDMAC
CALL/M(PASSING_A_FEATURE),(P1)
Passing Feature to A Macro Using a Variable
In order to pass a feature to a Macro using a Variable it is necessary to define in the macro declaration that the argument is a Variable (see above) and, when using the Macro, use the "@" to access to the feature as variable:
$$ Example of a MACRO Used with Feature passed as Varible
F(P1)=FEAT/POINT,CART,0,0,0,0,0,1
M(PASSING_A_FEATURE)=MACRO/FEATURE
DECL/LOCAL,DOUBLE, XX
XX=OBTAIN/F(@FEATURE),3
tmpString=ASSIGN/CONCAT('The X VALUE OF THE PASSED POINT IS: ',STR(XX))
TEXT/OPER,tmpString
ENDMAC
CALL/M(PASSING_A_FEATURE),'P1'
Passing Features and Variables to A Macro Using a Variable
A macro can receive as arguments both features and Variables.
In this case it is necessary to define in the macro declaration that the argument is a Variable or a Feature (see above) and, when using the Macro, use the "@" or "(" and ")" to access to the feature or variable:
$$ Example of a MACRO Used with Feature passed as Varible
F(P1)=FEAT/POINT,CART,0,0,0,0,0,1
F(P2)=FEAT/POINT,CART,1,0,0,0,0,1
M(PASSING_A_FEATURE_AND_A_VARIABLE)=MACRO/'FEATURE_DIRECT',FEATURE_AS_VARIABLE,MYVARIABLE
DECL/LOCAL,DOUBLE, XX
DECL/LOCAL,DOUBLE, XX1
XX=OBTAIN/F(FEATURE_DIRECT),3
XX1=OBTAIN/F(@FEATURE_AS_VARIABLE),3
tmpString=ASSIGN/CONCAT('The X VALUE OF THE POINT PASSED DIRECTLY IS: ',STR(XX))
- <code> TEXT/OPER,tmpString
tmpString=ASSIGN/CONCAT('The X VALUE OF THE POINT PASSED WITH VARIABLE IS: ',STR(XX1))
TEXT/OPER,tmpString
tmpString=ASSIGN/CONCAT('The Variable Passed is: ',STR(MYVARIABLE))
TEXT/OPER,tmpString
ENDMAC
CALL/M(PASSING_A_FEATURE),(P1),'P2',100