* dm24: STB-23 program define t_fpar local table $S_t local f = `table'_F[`1',`2'] local s = mod(`f',4096) if (`s'==0) { global S_1 = 0 /* recommended length */ global S_2 = 0 /* after decimals */ global S_4 = 1 /* lines */ global S_5 = 0 /* predecimals */ } else if (`s'==1) { local i = `table'_M[`1',`2'] if (`i'!=0) { /* Look up format from string named in matrix */ local z `table'_`i' global S_1 = substr("$`z'",2,.) local i = index("$S_1",".") if (`i'==0) { local i = max(index("$S_1","s"),index("$S_1","f"),index("$S_1","g")) } if (`i'<=1) { mac list } global S_1 = substr("$S_1",1,`i'-1) global S_2 0 global S_3 s global S_4 1 global S_5 0 exit } /* Give precidence to Column format. See also below */ local zz `table'_R`1' local z `table'_C`2' if ("$`z'"!="" | "$`zz'"!="") { local z "$`z'" if ("`z'"=="") { local z "$`zz'" } local z `table'_`z' global S_1 = substr("$`z'",2,.) local i = index("$S_1",".") if (`i'==0) { local i = max(index("$S_1","s"),index("$S_1","f"),index("$S_1","g")) } if ("$S_1"=="" | `i'==0) {noi di "Bad: |`i'| |`z'| |$S_1|" } * !! with blank entries, the following can fail (S_1=="") global S_1 = substr("$S_1",1,`i'-1) global S_2 0 global S_3 s global S_4 1 global S_5 0 exit } local v = `table'_V[`1',`2'] local sz = int(log(abs(`v'))/log(10)) if (`sz'==.) { local sz 1 } if (`sz' > 9 | `sz'<-3) { global S_1 0 /* recommended length */ global S_2 0 /* after decimals */ if (`sz'<0) { global S_3 h } /* type */ else { global S_3 g } global S_4 = 1 /* lines */ global S_5 0 } else { global S_1 = min(abs(`sz')+1,8) /* recommended length */ if (`v'==int(`v')) { global S_2 0 } else if (abs(`v'*10-int(`v'*10))<.0001) { global S_2 1 } else if (abs(`v'*100-int(`v'*100))<.001) { global S_2 2 } else { global S_2 = max(6-`sz',0) } /* after decimals */ global S_1 = $S_2+$S_1+2*($S_2>0)+(`v'<0) global S_3 = "f" /* type */ global S_5 = $S_1-$S_2 /* predecimals */ global S_4 = 1 /* lines */ } } else { local v `table'_`s' global S_1 = length("$`v'") /* recommended length */ global S_2 = 0 /* after decimals */ global S_3 = "s" /* type */ global S_4 = 1 /* lines */ global S_5 0 } end