[LON-CAPA-users] sharing variables among questions

H. K. Ng lon-capa-users@mail.lon-capa.org
Fri, 04 Mar 2005 13:56:48 -0500


One way to do this is to define all the molecular mass in a library. So 
create a file, say,

molecular_masses.library

In it put something like
<library>
<script type="loncapa/perl">
%masses =
     ( H20 => '18',
        O2 => '32'
      );
</script>
</library>

Then to use the values in your problem, include a line

<import>molecular_masses.library</import>
in your problem, if the lib is in the same directory as the problem. If not 
include the full path before the library name.

To use, say, the H20 mass in your problem use
$masses{'H2O'}

- hk

At 01:30 PM 3/4/2005, you wrote:
>Hello,
>
>Is there a way to define variables that could be used in multiple 
>problems?  For example, let's say you want to use a set of molecular 
>masses in several problems.  Rather than copy the problems, is there a way 
>to define a variable @mass that could be stored, and then 'called' from 
>another specific problem?
>
>Sally
>
>Dr. Sally S. Hunnicutt
>Assistant Chair, Associate Professor
>VCU Department of Chemistry
>1001 W. Main St.
>PO Box 842006
>Richmond VA 23284-2006
>804-827-0531
>sshunnic@vcu.edu
>
>
>_______________________________________________
>LON-CAPA-users mailing list
>LON-CAPA-users@mail.lon-capa.org
>http://mail.lon-capa.org/mailman/listinfo/lon-capa-users