[LON-CAPA-users] CAPA translator
Robert McQueen
lon-capa-users@mail.lon-capa.org
Mon, 18 Mar 2002 17:44:44 -0500
Hi Guy,
I think I get it now. But now I'm curious, why does the <m> tag perform
the conversion before the variable evaluation?
I also noticed that the sample problem below has another hidden topic to
be explored. [We've probably discussed this all before, but the answers
slip my mind.] The random function call below only has 2 arguments [which I
believe was acceptable in CAPA, but is not in LON-CAPA]. LON-CAPA assumes
the third argument to be a zero and hence sites it as an error [illegal
division by zero]. Is there an easy solution to this, such as adding a 2 as
the third argument? [I say 2 instead of 1 due to the limits set forth in the
CAPA manual for random(l,u,d) with l+d -> u]. How does CAPA handle the
missing third argument?
How about the 2 cases below:
$R=&random(10.0,30.0)
$speed=&random(2.98e4,2.98e4,0.)
>From: Guy Albertelli II <guy@albertelli.com>
>Reply-To: lon-capa-users@mail.lon-capa.org
>To: lon-capa-users@mail.lon-capa.org
>Subject: Re: [LON-CAPA-users] CAPA translator
>Date: 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.
>_______________________________________________
>LON-CAPA-users mailing list
>LON-CAPA-users@mail.lon-capa.org
>http://mail.lon-capa.org/mailman/listinfo/lon-capa-users
_________________________________________________________________
Chat with friends online, try MSN Messenger: http://messenger.msn.com