74 lines
1.7 KiB
TeX
74 lines
1.7 KiB
TeX
\section{Scripts}
|
|
\index{scripts}
|
|
Here is a simple example that draws the graph of $y=mx+b$.
|
|
|
|
\medskip
|
|
\verb$y=m*x+b$
|
|
|
|
\verb$m=1/2$
|
|
|
|
\verb$b=-3$
|
|
|
|
\verb$draw(y)$
|
|
|
|
\begin{center}
|
|
\includegraphics[scale=0.4]{1.png}
|
|
\end{center}
|
|
|
|
\noindent
|
|
Now suppose that we want to draw the graph
|
|
with a different $m$.
|
|
We could type in everything all over again, but it would be easier
|
|
in the long run to write a script.
|
|
Then we can go back and quickly change $m$ and $b$ as many times as we want.
|
|
|
|
\medskip
|
|
\noindent
|
|
To prepare a script, click on the Edit Script button.
|
|
Then enter the script commands, one per line, as shown above.
|
|
Then click on the Run Script button to see the graph.
|
|
|
|
\medskip
|
|
\noindent
|
|
Eigenmath runs a script by stepping through it line by line.
|
|
Each line is evaluated just like a regular command.
|
|
This continues until the end of the script is reached.
|
|
After the script runs, you can click Edit Script and go back and change something.
|
|
%By the way, Eigenmath automatically does a clear
|
|
%running a script.
|
|
|
|
\newpage
|
|
|
|
\noindent
|
|
Sometimes it is desirable to have a script print a few comments when it runs.
|
|
This can be accomplished by placing the desired text in quotes
|
|
on a single line.
|
|
For example, the script
|
|
|
|
\medskip
|
|
\verb$"Here is the value of pi."$
|
|
|
|
\verb$float(pi)$
|
|
|
|
\medskip
|
|
\noindent
|
|
displays the following when run.
|
|
|
|
\medskip
|
|
\verb$Here is the value of pi.$
|
|
|
|
$$3.14159$$
|
|
|
|
\medskip
|
|
\noindent
|
|
Eigenmath includes a simple debug facility.
|
|
Setting the variable $trace$ to 1 causes each line of the script to be
|
|
printed as the script runs.
|
|
Normally this setting would be the first line in the script.
|
|
|
|
\medskip
|
|
\verb$trace=1$
|
|
|
|
\verb$--Now each line of the script is printed as it runs.$
|
|
|