[LON-CAPA-users] CAPA translator
Guy Albertelli II
lon-capa-users@mail.lon-capa.org
Mon, 18 Mar 2002 11:05:30 -0500 (EST)
Hi Robert,
> I have an old question that popped into mind while revisiting the
> problem conversion script we use here at OU. How does one handle the
> situation below? Is there a way to do it other than using <display> tags?
> ---------------------
> ORIGINAL CAPA FORMAT:
> ---------------------
> /LET N11=random(1,4)
> /DIS(tex("\vskip .10in ","")) /DIS(tex("\input
> /OUp200lib/pictures/set8tab",""))
> /DIS(var_in_tex(N11))/DIS(tex(".tex","")) /DIS(tex("\end{center}",""))
>
> ---------------------
> LON-CAPA FORMAT:
> ---------------------
> <script type="loncapa/perl">
> $N11=&random(1,4);
> </script>
> <startouttext /><hr />
> <tex>\vskip .10in \input
> /OUp200lib/pictures/set8tab$N11.tex\end{center}</tex>
> <endouttext />
> ---------------------
> This would not work because of the misinterpretation of the "$" sign,
> correct?
Actually I think it would work. There will be a variable evaluation
pass after <tex> is parsed.
(Referencing the block diagram in the guts manual, we do a get_token,
on the <tex> which leads to callsub, which will handle the <tex> tag,
after handling it gets passed through the variable expansion)
The reason <m> tag didn't work with this, is because the calsub
routine for <m> did a tex->html translation before the variable
expansion.
In this case we are building a tex string so it is okay that variable
expanison takes place after the tag i doing being handled.
You should try it out.
Note that if all else fails this would work:
<script type="loncapa/perl">
$N11=&random(1,4);
$tabledata=&xmlparse('<tex>\vskip .10in \input '."\n".'/OUp200lib/pictures/set8tab'.$N11.'.tex\end{center}</tex>')
</script>
<startouttext /><hr />
$tabledata
<endouttext />
Or one could even do:
<script type="loncapa/perl">
$N11=&random(1,4);
$tabledata='';
if ($external::target eq 'tex') {
$tabledata='\vskip .10in \input
/OUp200lib/pictures/set8tab'.$N11.'.tex\end{center}</tex>';
}
</script>
<startouttext /><hr />
$tabledata
<endouttext />
And if we need to do an early var expanision pass I suggest mimicing
<m>
<tex eval="on">
--
albertel@msu.edu BM: n^20 t20 z20 qS
Guy Albertelli -7-9-8- O-
My parents just came back from a planet where the dominant lifeform
had no bilateral symmetry, and all I got was this stupid F-Shirt.