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

Home > creating a macro with an unknown number of parameters

Question
Kevin Furze · Apr 13, 2018

creating a macro with an unknown number of parameters

I use macros everyday, but its the first time I want to create a macro like this

I want to create a new macro whereby I can pass a variable amount of parameters

the macro (much simplified version) would be 

#define myMacro(%params)         $listBuild(any Number Of %params I pass in)

so I want to be able to call $$$myMacro(user,ID,vehicle)         ie 3 parameters would generate

$lb(user,ID,vehicle)

but equally I might want to call that same macro $$$myMacro(companyID)          ie 1 paramter and would generate

$lb(companyID)

so the question is, 

how can I create the macro without knowing how many parameters I'm passing in up front.

(Hope this makes sense)

kevin

#Caché

Source URL:https://community.intersystems.com/post/creating-macro-unknown-number-parameters