\begin{page}{HTXAdvPage5}{\Language{} paste-ins}
\centerline{\fbox{{\tt \thispage}}}\newline
\begin{scroll}

The {\it paste} and {\it patch} facility (see \downlink{previous page}{HTXAdvPage4})
is used to display (or hide) the \Language{} output
of an \Language{} command ({\tt\\axiomcommand})
included in a
\HyperName{} page.

A mechanism has been set up to {\it automatically} generate
these paste-ins. It amounts to replacing an
{\tt \\axiomcommand} by a {\tt \\pastecommand} in the
\HyperName{} page.

In the case of a \axiomOp{draw} \Language{} command
, where the result is to create an interactive viewport,
the appropriate command to use is {\tt \\pastegraph}.
The effect of this is to include (as the output)
the \Language{} generated {\it image} of the graph
as an active area. Clicking on it will put up an
interactive viewport.
The {\tt \\pastegraph} command should be used only when
the result of the associated \Language{} operation is
to {\it create} an interactive viewport. It is {\it not} necessarily
appropriate for all commands whose result
is a \axiomType{Two{}Dimensional{}Viewport} or \axiomType{Three{}Dimensional{}Viewport}.
The {\tt \\pastecommand} and {\tt \\pastegraph}
are  macros defined in {\bf util.ht}.



There is no automatic paste-in generation facility
for \Language{} piles (the {\tt \\begin\{axiomsrc\}} command).


The automatic paste-in generation mechanism works
by invoking \Language{} with a particular option.
\HyperName{} is also started automatically. It reads
the {\tt \\pastecommand} and {\tt \\pastegraph}
commands in all pages in a specified
{\bf somefile.ht}  and passes them to
\Language{} for evaluation. \HyperName{}
captures the output and writes it out (to a
file called {\bf somefile.pht}) as the body of
some {\it patch} definitions. The commands
encountered are written to a file
{\bf somefile.input} which you can {\tt )read} from an \Language{} session.
It also creates directories for the graphics
images encountered. Those files and directories
will be written under the {\it current} directory.
The idea is that you then include the {\it patch} definitions
in {\bf somefile.pht} in your local database using {\bf htadd}.


You can try this feature now. Edit a file called, say, {\bf trypaste.ht}
in a directory, say {\bf /tmp}. Put the following \HyperName{} text
in it.
\beginImportant
\newline
{\tt \\begin\{page\}\{TryPaste\}\{Trying out paste-in generation\}}\newline
{\tt \\begin\{scroll\}}\newline
{\tt \\pastecommand\{f z == z^2 \\bound\{f\}\}}\newline
{\tt \\pastegraph\{draw(f,-1..1) \\free\{f\}\}}\newline
{\tt \\pastecommand\{x:= f 3 \\free\{f\}\}}\newline
{\tt \\end\{scroll\}}\newline
{\tt \\end\{page\}}\newline
\endImportant

From the directory that contains the {\bf trypaste.ht},
issue
\centerline{
{\tt htadd -l ./trypaste.ht}
}
You will get the
{\bf ht.db} database file.
Set the environment variable {\tt HTPATH} so that
it points first to your directory and then the system directory.
In the {\bf /bin/csh}, you might use
\centerline{
{\tt setenv HTPATH /tmp:\$AXIOM/share/hypertex/pages}
}
Make sure that no {\bf trypaste.input} or {\bf trypaste.pht}
files exist in the directory.
Then issue
\centerline{
{\tt axiom -paste trypaste.ht}
}
 and wait for
\Language{} to finish.

There is a modification you will wish to make to
the {\bf trypaste.pht} file.
This is because the generated \HyperName{} text will assume that
the {\it viewport} data will be located in the
{\it system} directory.
\centerline{{\bf \env{AXIOM}/share/viewports}}
You may want to place your images in a different directory,
say, {\bf /u/sugar/viewports}.
If so, then change all occurences of
\beginImportant
\newline
{\tt \\env\{AXIOM\}/share/viewports/}
\centerline{{\it by}}
{\tt /u/sugar/viewports/}
\endImportant
in the file {\bf trypaste.pht}. The last step
is to include the {\it patch} definitions
in {\bf trypaste.pht} to your local database.
Issue
\centerline{
{\tt htadd -l ./trypaste.pht}
}
to update the database. If you have provided
a link to your pages from the {\tt RootPage}
via the {\tt \\localinfo} macro, you should now
be able to start \Language{} or \HyperName{}
and see the computed \Language{} output whenever you
click on the buttons to the left of each command.



\end{scroll}
\beginmenu
\menulink{Next Page --- Miscellaneous}{HTXAdvPage6}
\endmenu

\end{page}
