# [LON-CAPA-users] More elegant conditional text?

Todd Ruskell lon-capa-users@mail.lon-capa.org
Fri, 08 Feb 2008 12:16:23 -0700

Thanks all.  Turns out <parse> is exactly what I was looking for, as it
allows me to include even more than just mathematics in the random
block, although the &xmlparse() would also have worked.

Todd

Gerd Kortemeyer wrote:
> Hi,
>
> On Feb 7, 2008, at 7:46 PM, Ray Batchelor wrote:
>>
>> <script type="loncapa/perl">$a='$ \mathrm{KE}_1=(1/2)M_1v_1^2 $'; >>$b='$\mathrm{E}_2=M_2c^2$';
>> $c='$ \mathrm{P}_3=M_3v_3^2 $'; >> >>$choice=&random(0,2,1);
>>
>> @array=($a,$b,$c);</script> >> <startouttext /><p><m eval="on">$array[$choice] </m></p><endouttext /> >> >> Possibly someone can tell me that this is not robust? > > I believe it's equally robust. Incorporating Ray's solution, we have > four magic incantations: > > <problem> > <script type="loncapa/perl"> >$array = '<m>$E=mc^2$</m>';
> $array = &xmlparse('<m>$\nabla E=\varrho/\varepsilon_0$</m>'); >$array = '$E=mv^2/2$';
> $array = '\nabla\times E=-\partial B/\partial t'; > </script> > <startouttext /> > It is <parse>$array</parse>, but also <display>$array</display> - > strange. > And there is always <m eval="on">$array</m> and <m eval="on">$>$array \$</m>.
> <endouttext />
> </problem>
>
> As always in LON-CAPA, the number of possibilities is limitless ... or
> at least four.
>
> - Gerd.
>
> _______________________________________________
> LON-CAPA-users mailing list
> LON-CAPA-users@mail.lon-capa.org
> http://mail.lon-capa.org/mailman/listinfo/lon-capa-users

--
Dr. Todd Ruskell
Senior Lecturer, Department of Physics       Office:  Meyer Hall 326
Colorado School of Mines                     Phone: 303-384-2080
1523 Illinois Street                         Fax: 303-273-3919
Golden, CO 80401