-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathassert_macros.ado
34 lines (34 loc) · 908 Bytes
/
assert_macros.ado
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
capture program drop assert_macros
program define assert_macros
args macros
///////////////////////////////////////////////////////////////////////////////
// Description:
// ------------
// Asserts that global macro(s) are defined (not empty).
//
// Syntax:
// -------
// assert_macros "macro1 macro2 ..."
// MWE:
// ----
// sysuse auto
// global m1 price make
// corr_pval
// assert_macros "m1 m2"
//////////////////////////////////////////////////////////////////////////////
if "`macros'"!="" {
foreach global_macro in `macros' {
dis "Checking `global_macro':"
capture assert "$`global_macro'" != ""
if _rc == 0 {
display "`global_macro' contains: $`global_macro'"
}
else if _rc != 0 {
display in red "`global_macro' is empty (not defined)."
}
}
}
else {
noisily dis "No macros stated..."
}
end