📄 opts_exclusive.ado
字号:
*! version 1.0.0 25may2004
program opts_exclusive
version 8.2
args opts optname errcode
local n : word count `opts'
if `n' < 2 { // no error message or return code
exit
}
di in smcl as err "{p}"
if `"`optname'"' ~= "" {
di in smcl as err `"option `optname'() invalid;"'
}
di in smcl as err "only one of"
if `n' == 2 {
di in smcl as err `"`: word 1 of `opts'' "' ///
`"or `: word 2 of `opts''"'
}
else {
forvalues i=1/`=`n'-1' {
di in smcl as err `"`:word `i' of `opts'',"'
}
di in smcl as err `"or `:word `n' of `opts''"'
}
di in smcl as err "are allowed{p_end}"
if `"`errcode'"' != "" {
exit `errcode'
}
else {
exit 198
}
end
exit
opts_exclusive:
display error message and exit for mutually exclusive options
-opts_exclusive "a b c"- exits with r(198) and displays:
only one of a, b, or c are allowed
-opts_exclusive "a b c" xyz- exits with r(198) and displays:
option xyz() invalid; only one of a, b, or c are allowed
-opts_exclusive "a b" "" 99- exits with r(99) and displays:
only one of a or b are allowed
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -