= SPSS Macro Arguments = '''Arguments''' to SPSS macros need to be explicitly parsed on the macro definition. <> ---- == Declaration == {{{ define !foo(variables=!cmdend) compute foo=!variables. enddefine. !foo variables=bar baz. }}} The available functions are: ||'''Function''' ||'''Behavior''' || ||`!CHAREND('C')` ||Consume all tokens until `C` || ||`!CMDEND` ||Consume all tokens until the end of the command|| ||`!ECNLOSE('S','E')`||Consume all tokens starting from `S` until `E` || ||`!TOKENS(N)` ||Consume `N` tokens || ||`!POSITIONAL` ||Used with one of the above functions || Note that arguments are tokenized ''before'' being exposed to the macro expansion. ---- == Usage == If an argument is bound to a name, it becomes a '''named argument'''. If the `!POSITIONAL` function is used, it becomes a '''positional argument'''. ---- === Named Arguments === Named arguments are accessed by their name prefixed with an exclamation mark (`!`). {{{ define !foo(bar=!tokens(1) /baz=!tokens(1)) compute !bar=0. compute !baz=0. !enddefine. !foo bar=x baz=y. }}} In this example, the variables `x` and `y` will be created. ---- === Positional Arguments === Positional arguments are set into sequential integer names prefixed with an exclamation mark (`!`) (i.e. `!1`, `!2`, and so on). {{{ define !foo(!positional !tokens(1) /!positional !tokens(1)) compute !1=0. compute !2=0. !enddefine. !foo x y. }}} In this example also, the variables `x` and `y` will be created. The entire series of positional arguments as a space-delimited string can be accessed as `!*`. ---- === Default Values === ---- CategoryRicottone