Say I have a global macro x
, how do I extract the number of items (space-separated unquoted words) in it?
global x abc xyz foo
I am sure it is an easy task, but I've looked in help macro
and haven't find anything so far.
Say I have a global macro x
, how do I extract the number of items (space-separated unquoted words) in it?
global x abc xyz foo
I am sure it is an easy task, but I've looked in help macro
and haven't find anything so far.
Yeah, it was right there in the manual. The macro function word count
would do the job.
. global x abc xyz foo
. local len_x : word count $x
. di `len_x'
3
Alternatively,
. di wordcount("$x")
3
Note the need to quote the global macro in this case.