Published on InterSystems Developer Community (https://community.intersystems.com)

Home > How to handlle Variable Number of Parameters in Macro?

Question
alex chang · Sep 13, 2020

How to handlle Variable Number of Parameters in Macro?

Common macro def as following

 

#def AnyNumber(%args) for i=1:1:$listlength(%args) { Write $listget(%args, i)}

Using this marcro in objectscript code:

ClassMethod Test() as %Status {

     $$$AnyNumber($lb(1,2,3))

}

if ths args is literal value , Iit worked great. But  When I want pass Objects, It's not working

$$$AnyNumber($lb(##class(someClass).%New()))

I know I can pass a %ListObjects , If I want more shorter Line. How can I do this.

Tks

#ObjectScript #Ensemble

Source URL:https://community.intersystems.com/post/how-handlle-variable-number-parameters-macro