Next: getlabels()
Up: MacAnova Help File
Previous: gethistory()
Contents
Usage:
getkeywords(arg1 [,arg2, arg3 ...]), arg1, arg2, ... arbitrary.
|
Keywords:
syntax, macros
result <- getkeywords(arg1 [, arg2, ..., argK]) returns a CHARACTER
vector of length K. If argument i is a keyword phrase, result[i] is the
keyword name; otherwise result[i] is "".
Cmd> getkeywords(cos:3, kappa:PI,a,"b",3)
(1) "cos"
(2) "kappa"
(3) ""
(4) ""
(5) ""
The principal use for getkeywords() is in a macro. It is one of the
tools for analyzing the argument list to a macro. For example, it is
sometimes necessary to identify which arguments are keyword phrases and
which are not.
Here is a snippet of code that might be in a macro.
@keynames <- getkeywords($0) # check entire argument list
@keynames <- @keynames[!ismissing(@keynames)] # extract keyword names
if (!isnull(@keynames)){
@legalkeys <- vector("short","long","narrow","wide")
for (@i,1,length(@keynames)){
if (match(@keynames[@i], @legalkeys, 0) == 0) {
error(paste(@keynames[@i],"is not a legal keyword"))
}
}
}
This checks to see that all keywords in the argument list are in a list
of permissible keyword names.
See also argvalue(), keyvalue(), 'keywords', 'macro_syntax', 'macros',
match().
Gary Oehlert
2003-01-15