Hi all,

 

I’m trying to write a script that will produce a LaTeX table as output – basically a customized version of tabprint. Here’s the basic idea:

<hansl>

matrix doh = mnormal(1,3) # this would be a coefficient vector, e.g.

 

string fmt = "%.4g "

string baz = "doh[1]"

loop i=2..cols(doh) # build up the format and argument strings

    fmt ~= " & %.4g "

    baz ~= ", doh[$i]"

endloop

fmt

baz

 

sprintf Foo "\"%s\"\n", fmt

Foo

 

# this printf is what I want, but I want to use the “fmt” string above

printf "%.4g & %.4g & %.4g\n", @baz

 

# this seems like it should work, but I get a “syntax error”

sprintf bar Foo, @baz

</hansl>

 

I’m still trying to get my head around (s)printf, string substitution, etc., so I’m probably missing something straightforward. Any suggestions welcome!

 

Thanks,

PS