Good morning!
I am trying to program a sort of string template (StringTemplate[]) in Mathematica. However, I am having some issues to use external variables inside this template. Figure 1 illustrates the desired text output of the mentioned string template. This output is going to be used as input for another program. On this way, number and text positions should be strictly identical to the example presented in Figure 1.
Figure 1 - Desired text output.
I have tried many ways to achieve my goal, but without success. Figure 2 presents a exemple of what I have tried:
TEST := ToString[NumberForm[0.82544479318, 11]];
CODIGO := StringTemplate["
C ----------------------------------------------------------------------
C [R] Matrix
C ----------------------------------------------------------------------
$VINTAGE, 1,
X0001AX0001X 0.82544479318
X0001AX0001X`1`"][TEST]
The result is:
In[73]:= CODIGO
Out[73]= "
C ----------------------------------------------------------------------
C [R] Matrix
C ----------------------------------------------------------------------
$VINTAGE, 1,
X0001AX0001X 0.82544479318
X0001AX0001X0.82544479318"
PaddedForm is not working too:
In[74]:= TEST :=
ToString[PaddedForm[NumberForm[0.82544479318, 11], 28]];
CODIGO := StringTemplate["
C ----------------------------------------------------------------------
C [R] Matrix
C ----------------------------------------------------------------------
$VINTAGE, 1,
X0001AX0001X 0.82544479318
X0001AX0001X`1`"][TEST]
In[77]:= CODIGO
Out[77]= "
C ----------------------------------------------------------------------
C [R] Matrix
C ----------------------------------------------------------------------
$VINTAGE, 1,
X0001AX0001X 0.82544479318
X0001AX0001X0.82544479318"
It is important to note that numbers start in an imaginary column and "grow" to the left as illustrated in the figure below.
Maybe it's something easy to solve , but I'm not getting it.
Thank you in advance for any advice, tip and/or help!
--Luiz Gutierres