Annotation of loncom/html/adm/help/tex/Variables_in_Scripts.tex, revision 1.5
1.2 bowersj2 1: \label{Variables_in_Scripts}
1.1 bowersj2 2:
3: Variables can be used later in the same script. For instance, we can add
4: another line below the \texttt{\$variable} line as such:
5:
1.5 ! raeburn 6: \begin{verbatim}
! 7: $variable2 = $variable+2;
! 8: \end{verbatim}
1.1 bowersj2 9:
10: Now there is a variable called \texttt{\$variable2} with the the number {}``5''
11: as its value.
12:
13: Variables can also be used in \emph{strings}\index{strings}, which are a
14: sequence of letters. The underlying language of the script, Perl, has a very
15: large number of ways of using variables in strings, but the easiest and most
16: common way is to use normal double-quotes and just spell out the name of
17: the variable you want to use in the string, like this:
18:
1.5 ! raeburn 19: \begin{verbatim}
! 20: $stringVar = "I have a variable with the value $variable.";
! 21: \end{verbatim}
1.1 bowersj2 22:
23: This will put the string {}``I have a variable with the value 3.'' into
24: the variable named {}``stringVar''.
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>