program define defv *! version 1.1.2 STB-40 dm50 version 4.0 global d_V "note" * to record definitions so that they are distinct from notes, * remove the asterisk (*) from the next line: * global d_V "defV" parse "`*'", parse(" :") if "`1'" == "by" { local op 0 while !`op' { local b "`b'`1' " local op = "`1'"==":" mac shift } } if "`2'" == "?" { xx `1' exit } local v "`1'" if "`1'"=="byte" | "`1'"=="int" | "`1'"=="long" | "`1'"=="float" /* */ | "`1'"=="double" { local v "`2'" } local op = index("`v'", "=") if `op' { local v = substr("`v'", 1, `op'-1) } local op "`b'generate" qui capture confirm new var `v' if _rc == 110 { local op "`b'replace" local j : char `v'[${d_V}0] } else if _rc { error _rc } local j = cond("`j'" == "", 1, `j'+1) nobreak { `op' `*' char `v'[${d_V}0] `j' char `v'[${d_V}`j'] `op' `*' } end program define xx local varlist "req ex" parse "`*'" local j : char `1'[${d_V}0] if "`j'" != "" { di in ye "`1':" local i 1 while `i' <= `j' { local b : char `1'[${d_V}`i'] if "`b'" != "" { di in gr %4.0g " `i'.", "`b'" } local i = `i' + 1 } } end