* dm24: STB-23 program define t_print local options " Table(string)" parse "`*'" if ("`table'"=="") { local table $S_t } global S_t `table' local overlen 0 local rows = rowsof("`table'_F") local cols = colsof("`table'_F") local j 1 while (`j'<=`cols') { local i 1 local maxlen 0 local type 1 local afterd 0 local predec 0 local maxxs 0 while (`i'<=`rows') { t_fpar `i' `j' local mytype = index("shfg","$S_3") if (`mytype'==1 ) { local maxxs = max(`maxxs',$S_1) } else { local maxlen = max(`maxlen',$S_1) } if (`mytype'>`type') { local type `mytype' } if ($S_2>`afterd') { local afterd $S_2 } if ($S_5>`predec') { local predec $S_5 } local i = `i' + 1 } if (`type'==1) { local maxlen `maxxs' } if (`type'==2 | `type'==4) { local maxlen = max(12,`maxlen',`maxxs') } if (`type'==3) { local maxlen = max(`maxlen',`afterd'+`predec'+1,`maxxs') /* the +1 is not always necessary. it comes because you may try to match 12345. with 1.23456 */ if (`maxlen'>12) { local maxlen = max(12,`maxxs') local type 4 } } global `table'_c`j' `maxlen' global `table'_t`j' `type' global `table'_a`j' `afterd' local overlen = `overlen' + `maxlen' + 1 local j = `j' + 1 } di if ("$`table'_tit"!="") { local waste = `overlen' - length("$`table'_tit") + 1 if (`waste'>1) { local waste = int(`waste'/2)+1 } else { local waste 1 } di _col(`waste') in green "$`table'_tit" _n } local i 1 while (`i'<=`rows') { local j 1 while (`j'<=`cols') { local z `table'_c`j' local maxlen $`z' /* and other stuff .. its complicated */ local z `table'_t`j' local type $`z' local z `table'_a`j' local afterd $`z' t_fval `i' `j' `maxlen' `type' `afterd' local mc = `maxlen' + 2 if ($S_4) { di " " $S_1 $S_2 "$S_3" _col(`mc') _c } else { di " " $S_1 $S_2 $S_3 _col(`mc') _c } local j = `j' + 1 } di local i = `i' + 1 } end