\chapter{Advanced Features}
\markboth{Advanced Features}{}

\section{Affecting the session}
\markright{Affecting the session}

\subsection{Setting font and size of text}
If you want to change the font format of some text, even as small as one character, LMC one end of the text. Drag the mouse to highlight the text that you want to change. Choose \menu{Tools}{Font} from the menu bar. A \wid{Font} dialog, as illustrated in Figure 4.1, shows up. In a standard way, select your preferred font format including style and size, then LMC the \wid{OK} button.

\begin{figure}
\begin{center}
\epsfig{figure=font.eps, width=4.0in}
\end{center}
\caption{\wid{Font} Dialog}
\end{figure}

The selected text on the canvas is changed to the selected font format. As there is no font information in the \program{pic} language, the IR is not changed. Consequently, the setting of the font and size affects only the appearance of the text in the canvas for the current session.

In \program{pic}, text in quotes is passed verbatim to \program{troff} which does the font and size changes according to \program{troff} font and size change commands in the quoted text. So \program{pic} itself does nothing with fonts and sizes. To be able to see what the result would look like when printed, use these font and size settings session commands to make the font and size of the displayed text be what \program{troff} thinks it is. You can make the \program{troff} commands themselves invisible so that they are not displayed. For instance, assuming that the current canvas font is Times Roman, to get the result of a box with ``Hello'' in Helvetica, size 8, follow the steps:

\begin{enumerate}
\item Insert \code{box} \verb+"\+\code{fH}\verb+\+\code{s8Hello}\verb+\+\code{s0}\verb+\+\code{fP}\verb+"+ into the IR. The canvas is drawn with a box centered with text ``\verb+\+fH\verb+\+s8Hello\verb+\+s0\verb+\+fP'', as illustrated in Figure 4.2. 
\item Select ``\verb+\+fH\verb+\+s8'' on the canvas, choose 
\menu{Tools}{Font} from the menu bar, select \wid{Invisible} in the \wid{Font} dialog, or set the size to 0.
\item LMC the \wid{OK} button. ``\verb+\+fH\verb+\+s8'' is made invisible and zero width on the canvas.
\item Select ``\verb+\+s0\verb+\+fP'' on the canvas, choose 
\menu{Tools}{Font} from the menu bar, select \wid{Invisible} in the \wid{Font} dialog, or set the size to 0.
\item LMC the \wid{OK} button. ``\verb+\+s0\verb+\+fP'' is made invisible and zero width on the canvas.
\item Select ``Hello'' on the canvas, choose \menu{Tools}{Font} from the menu bar and set the font to Helvetica or Arial, size 8.
\item LMC the \wid{OK} button. You see ``\footnotesize \textsf{Hello}\normalsize'' in Helvetica size 8 centered in the box on the canvas, as illustrated in Figure 4.3. 
\end{enumerate}

\begin{figure}
\begin{center}
\parbox{3.0in}{
\begin{center}
\includegraphics{font1.eps}
\end{center}
\caption{\small A sample of setting font, before}
}
\parbox{3.0in}{
\begin{center}
\includegraphics{font2.eps}
\end{center}
\caption{\small A sample of setting font, after}
}
\end{center}
\end{figure}
\normalsize
Once any text is set to invisible, you cannot select it on the canvas. To see the invisible text on the canvas, RMC the object which the text is an attribute, choose \wid{Reset Font}. Alternatively, you can select the object by LMCing it. Then choose \wid{Reset Font} from \wid{Edit} menu. In either case, the font of the selected object is set back to the system default font.

\subsection{Preferences}
Choose \menu{Tools}{Preferences} from menu bar. A \wid{Preferences} dialog, 
as illustrated in Figure 4.4, shows up. You can set your preferred values 
for the attributes of \token{box}, \token{circle}, \token{ellipse}, 
\token{line}, \token{arrow}, \token{arc}, and \token{spline}. After you are 
done, LMC the \wid{OK} button.

The changes you make will affect the new inserted objects by using the 
palette from now on, until the next time you change the preferences again. 
By this means, whenever you add a primitive into the IR by LMCing the 
buttons on the palette, the preferred attributes of that primitive that you set in the \wid{Preferences} dialog are added to the primitive automatically as they are added to the IR. For instance, if you change the line style of \token{box} to \token{dotted}, then \code{dotted} will be added to the IR to each \code{box} that is inserted into the IR by LMCing the \wid{box} button on the palette after the preference is changed. 

\begin{figure} 
\begin{center}
\epsfig{figure=pref.eps, width=4.5in}
\end{center}
\caption{\wid{Preferences} Dialog} 
\end{figure}

\section{Affecting the IR}
\markright{Affecting the IR}

\subsection{Changing values of variables}
The \program{pic} program has 20 variables, \eg\ \token{boxwid} and \token{boxht}. There are two ways to change any of these values:  

\begin{itemize}
\item With the palette:
 \begin{enumerate} 
 \item LMC the \wid{Variables} button on the palette. A \wid{Variables} dialog, as illustrated in Figure 4.5, shows up. 
 \item Choose the variable \picvar{var} that you want to change from the field's pop-up list. \picvar{var}'s value at the CIP and the default value show up. 
 \item Type a valid \program{pic} expression \picvar{expr} into the \wid{New Value} field. 
 \item LMC the \wid{OK} button.
 \end{enumerate}

\item With the keyboard: type assignment for the variable \picvar{var} that you want to change, \eg\ \picvar{var}\code{=}\picvar{expr}.
\end{itemize}

\begin{figure}
\begin{center}
\epsfig{figure=variable.eps, width=3.0 in}
\end{center}
\caption{\wid{Variables} Dialog}
\end{figure}

An assignment statement for the changed variable, \eg\ \picvar{var}\code{=}\picvar{expr}, is added to the IR at the CIP. The canvas is redrawn according to the current complete 
IR.

\subsection{Changing attributes of an existing object}
You can change the attributes of an existing object with the palette 
during insertion, as described in Section 3.2.2, or you can change the 
attributes later in any of the following ways:

\begin{itemize}
\item Direct manipulation:
 \begin{itemize} 
 \item With the palette:
  \begin{enumerate}
  \item Select the object, as described in Section 3.1.4. The available attribute tokens of the selected object show up in the attributes area on the palette.
  \item Make the changes.
  \item LMC the attribute buttons to change the values. The modifications are saved into the IR.
  \end{enumerate}

 \item With the pop-up menu:
  \begin{enumerate}
  \item RMC the object. 
  \item Choose \wid{Change Attribute} from the pop-up menu. An \widvar{Object} \wid{Attributes} dialog shows up based on what kind of object is selected. Figure 4.6 illustrates a \wid{Box Attributes} dialog.

\begin{figure}
\begin{center}
\epsfig{figure=boxattrdlg.eps, width=4.0 in}
\end{center}
\caption{\wid{Box Attributes} Dialog}
\end{figure}

  \item Make the changes. 
  \item LMC the \wid{OK} button. The modifications are saved into the IR.  
  \end{enumerate}

 \end{itemize}

\item With the keyboard: Find the object in the EW whose attributes you want to change. Add or change the values of attributes.
\end{itemize}

In any case, the picture on the canvas is redrawn from the complete IR.

\subsection{Constructs}
\subsubsection{Loops}
\begin{itemize}
\item With the palette:
 \begin{enumerate} 
 \item LMC the \wid{Constructs} button on the palette. A \wid{Constructs} dialog, as illustrated in Figure 4.7, shows up.

\begin{figure}
\begin{center}
\epsfig{figure=loop.eps, width=4.0 in}
\end{center}
\caption{\wid{Constructs} Dialog - Loop}
\end{figure}

 \item If the \wid{Loop} tab is not in front of the other tabs, LMC the \wid{Loop} tab.
 \item Fill in the parts of the \token{for} statement. The parts are \wid{for}, \wid{to}, \wid{by}, and \wid{do}.
 \item LMC the \wid{OK} button.
 \end{enumerate}

\item With the keyboard: Type \wid{f o r} \textvisiblespace\ \picvar{expr1} \textvisiblespace\ \wid{t o} \textvisiblespace\ \picvar{expr2} \textvisiblespace\ \wid{b y} \textvisiblespace\ \picvar{expr3} \textvisiblespace\ \wid{d o} \textvisiblespace\ \{\ \picvar{anything} \}\ at the CIP.

\end{itemize}

In any case, \code{for} \picvar{expr1} \code{to} \picvar{expr2} \code{by} \picvar{expr3} \code{do} \{\ \picvar{anything} \}\ is added to the IR at the CIP. The picture on the canvas is redrawn from the complete IR.

\subsubsection{Conditionals}
\begin{itemize}
\item With the palette:

 \begin{enumerate} 
 \item LMC the \wid{Constructs} button on the palette. A \wid{Constructs} dialog, as illustrated in Figure 4.7, shows up. 
 \item  If the \wid{Conditional} tab is not in front of the other tabs, LMC the \wid{Conditional} tab. An empty \token{if} statement shows up, as illustrated in Figure 4.8.

\begin{figure}
\begin{center}
\epsfig{figure=condition.eps, width=4.0 in}
\end{center}
\caption{\wid{Constructs} Dialog - Conditional}
\end{figure}

 \item Fill in the parts of the \token{if} statement. The parts are \wid{if}, \wid{then} and \wid{else}. 
 \item LMC the \wid{OK} button.
 \end{enumerate} 

\item With the keyboard: Type \wid{i f} \textvisiblespace\ \picvar{expression} \textvisiblespace\ \wid{t h e n} \textvisiblespace\ \{\ \picvar{anything1} \}\ \textvisiblespace\ \wid{e l s e} \textvisiblespace\ \{\ \picvar{anything2} \}\ at the CIP.
\end{itemize}
 
In any case, \code{if} \picvar{expression} \code{then} \{\ \picvar{anything1} \}\ \code{else} \{\ \picvar{anything2} \}\ is added to the IR at the CIP. The picture on the canvas is redrawn from the complete IR.

\subsubsection{Blocks}
\begin{itemize}
\item With the palette: 

 \begin{enumerate}
 \item LMC the \wid{Constructs} button on the palette. A \wid{Constructs} dialog, as illustrated in Figure 4.7, shows up. 
 \item If the \wid{Block} tab is not in front of the other tabs, LMC the \wid{Block} tab. An empty block statement shows up, as illustrated in Figure 4.9.

\begin{figure}
\begin{center}
\epsfig{figure=block.eps, width=4.0 in}
\end{center}
\caption{\wid{Constructs} Dialog - Block}
\end{figure}

 \item Fill in the parts of the block statement. The parts are block name and body.
 \item LMC the \wid{OK} button.
 \end{enumerate} 

\item With the keyboard: Type \picvar{blockname} \wid{:} \{\ \picvar{anything} \}\ at the CIP. 
\end{itemize}

In any case, \picvar{blockname} \code{:} \{\ \picvar{anything} \}\ is added to the IR at the CIP. The picture on the canvas is redrawn from the complete IR.

\subsection{Macros}
\subsubsection{Define}
\begin{itemize}
\item With the palette:
 \begin{enumerate}
 \item LMC the \wid{Macros} button on the palette. A \wid{Macros} dialog, as illustrated in Figure 4.10, shows up.

\begin{figure}
\begin{center}
\epsfig{figure=define.eps, height=2.0 in}
\end{center}
\caption{\wid{Macros} Dialog - Define}
\end{figure}
 
 \item If the \wid{Define} tab is not in front of the other tabs, LMC the \wid{Define} tab.
 \item Fill in the parts of the \token{define} statement. The parts are macro name and replacement text.
 \item LMC the \wid{OK} button.
 \end{enumerate} 

\item With the keyboard: Type \wid{d e f i n e} \textvisiblespace\ \picvar{name} \textvisiblespace\ \{\ \picvar{replacement text} \}\ at the CIP.

\end{itemize}

In any case, \code{define} \picvar{name} \{\ \picvar{replacement text} \}\ is added to the IR at the CIP.  The picture on the canvas is redrawn from the complete IR.

\subsubsection{Undefine}
\begin{itemize}
\item With the palette:
 \begin{enumerate}
 \item LMC the \wid{Macros} button on the palette. A \wid{Macros} dialog, as illustrated in Figure 4.10, shows up.
 \item If the \wid{Undefine} tab is not shown in front of other tabs, LMC the \wid{Undefine} tab. An empty \token{undef} statement, as illustrated in Figure 4.11, shows up.

\begin{figure}
\begin{center}
\epsfig{figure=undef.eps, height=2.0 in}
\end{center}
\caption{\wid{Macros} Dialog - Undefine}
\end{figure}

 \item Fill in the macro name that you want to undefine in the \token{undef} statement.
 \item LMC the \wid{OK} button.
 \end{enumerate} 

\item With the keyboard: Type \wid{u n d e f} \textvisiblespace\ \picvar{macro-name} at the CIP.
\end{itemize}

In any case, \code{undef} \picvar{macro-name} is added to the IR at the CIP.  The picture on the canvas is redrawn from the complete IR.

\subsection{File copy}
\subsubsection{Copy}
\begin{itemize}
\item With the palette:
 \begin{enumerate}
 \item LMC the \wid{File Copy} button on the palette. A \wid{File Copy} dialog, as illustrated in Figure 4.12, shows up.

\begin{figure}
\begin{center}
\epsfig{figure=copy.eps, height = 2.0 in}
\end{center}
\caption{\wid{File Copy} Dialog - Copy}
\end{figure}

 \item If the \wid{Copy} tab is not in front of the other tabs, LMC the \wid{Copy} tab.
 \item Fill in the name of the file that you want to copy in the \token{copy} statement. 
 \item LMC the \wid{OK} button.
 \end{enumerate} 

\item With the keyboard: Type \wid{c o p y} \textvisiblespace\ \widquote\ \picvar{filename}\ \widquote\ at the CIP.
\end{itemize}

In any case, \code{copy} \codequote\picvar{filename}\codequote\ is added to the IR at the CIP.  The picture on the canvas is redrawn from the complete IR.

\subsubsection{Copy Through}
\begin{itemize}
\item With the palette:
 \begin{enumerate}
 \item LMC the \wid{File Copy} button on the palette. A \wid{File Copy} dialog, as illustrated in Figure 4.12, shows up.
 \item If the \wid{Copy Through} tab is not in front of the other tabs, LMC the \wid{Copy Through} tab. An empty \token{copy thru} statement is shown up, as illustrated in Figure 4.13.

\begin{figure}
\begin{center}
\epsfig{figure=copythru.eps, height=2.0 in}
\end{center}
\caption{\wid{File Copy} Dialog - Copy Through}
\end{figure}

 \item Fill in the parts of the \token{copy thru} statement. The parts are file name and macro name or macro replacement text. 
 \item LMC the \wid{OK} button.
 \end{enumerate} 

\item With the keyboard: Type \wid{ c o p y}\ \textvisiblespace\ \widquote\ \picvar{file}\ \widquote\ \textvisiblespace\ \wid{t h r u}\ \textvisiblespace\ \picvar{macro-name}\ or \wid{c o p y}\  \textvisiblespace\ \widquote\ \picvar{file}\ \widquote\ \textvisiblespace\ \wid{t h r u} \textvisiblespace\ \{\ \picvar{macro replacement text} \}\ at the CIP.
\end{itemize}

In any case, \code{copy}\ \codequote\picvar{file}\codequote\ \code{thru}\ \picvar{macro-name} or \code{copy} \codequote\picvar{file}\codequote\ \code{thru} \{\ \picvar{macro replacement text} \}\ is added to the IR at the CIP. The picture on the canvas is redrawn from the complete IR.

\subsubsection{sh}
\begin{itemize}
\item With the palette:

 \begin{enumerate}
 \item LMC the \wid{File Copy} button on the palette. A \wid{File Copy} dialog, as illustrated in Figure 4.12, shows up.
 \item If the \wid{sh} tab is not in front of the other tabs, LMC the \wid{sh} tab. An empty \token{sh} statement is shown up, as illustrated in Figure 4.14.

\begin{figure}
\begin{center}
\epsfig{figure=sh.eps, height=2.0 in}
\end{center}
\caption{\wid{File Copy} Dialog - sh}
\end{figure}

 \item Fill in the body of the \token{sh} statement. 
 \item LMC the \wid{OK} button. 
 \end{enumerate}

\item With the keyboard: Type \wid{s h} \textvisiblespace\ \{\ \picvar{anything} \}\ at the CIP.
\end{itemize}
In any case, \code{sh} \{\ \picvar{anything} \}\ is added to the IR at the CIP.  The picture on the canvas is redrawn from the complete IR.

\subsection{Labelling}
\begin{itemize}
\item With the palette:
 \begin{enumerate}
 \item LMC the \wid{Label} button on the palette. The CIP moves to the beginning of the being-edited object.
 \item Type the name of the label, beginning with an uppercase letter. 
 \item Type \wid{:} to signal the end of label name. The CIP moves back to wherever it is before LMCing the \wid{Label} button. 
 \end{enumerate}

\item With the keyboard:
 \begin{enumerate}
 \item Find the object in the EW to which you want to add a label and set the CIP to the beginning of the object.
 \item Type the name of the label, beginning with an uppercase letter.
 \item Type \wid{:} to signal the end of the label name.
 \end{enumerate}

\end{itemize}

In either case, the label is added to the being-edited object in the IR.

























