Within the TAE Terminal Monitor (TM), operating in ASCII mode, when a proc specifies OPTIONS=SELFTUTOR on the PROCESS or PROCEDURE command, TM turns over the responsibility for interactive parameter acquisition to the proc; the Terminal Monitor does not do the tutoring. When the user requests tutor for a SELFTUTOR proc, the proc is executed immediately to perform its own version of tutor.
When TAE receives an initial tutor request for a proc declared SELFTUTOR, a new implicit local integer variable, "_TUTOR", is set to one as a flag to the proc. If the proc is a process, TAE prepares a V-block (or vm object) with the default values defined in the PDF, and passes the V-block to the process; this V-block includes the _TUTOR flag. If the proc is a procedure, TAE begins execution of the procedure with the local variable _TUTOR set to one.
Consider the following procedure example:
procedure options=selftutor
parm long real ! longitude
parm lat real ! latitude
parm satid ! satellite
body
if (_tutor)
GetEarthPosition long=long lat=lat
GetSatId satid=satid
end-if
! long, lat, and satid available for use here
.
.
.
end-proc
When the user requests tutor for this procedure, the procedure is executed with the _TUTOR flag set. The procedure performs its self-tutor by running a proc, GetEarthPosition, that graphically interacts with the user to obtain a latitude and longitude. Another interactive proc, GetSatld, is then run to allow the user to select from a list of currently available satellites. If this example procedure is run from command mode, TAE sets _TUTOR to zero and the execution of GetEarthPosition and GetSatId is bypassed.
The following page (Example 1) shows the skeleton of a TAE process configured for self-tutor. The two pages following that (Example 2) show a process example where dynamic tutor is used to satisfy the self-tutor request. In the second example, self-tutor is used to allow the process to access a data base and fill in valid lists in preparation for the initial tutor session.
EXAMPLE 1
---------
/*****
self-tutor skeleton.
Note that the PDF for this program
must have the following form:
process options=selftutor
...
end-proc
*****/
#include "taeconf.inp"
#include "parblk.inc"
#include "terminc.inc"
main( )
{
Id vmid, Vm_New( );
CODE Vm_ReadFromTM( );
struct VARIABLE *v;
struct VARIABLE *Vm_Find( );
vmid = Vm_New (P_ABORT);
Vm_ReadFromTM (vmid);
v = Vm_Find (vmid, "_tutor"); /* get _tutor */
if (IVAL(*v,O)) /* if tutor == 1 */
{
/* perform self-tutor here */
t_write ("hello from self-tutor", T_STDCC);
}
/* normal program execution */
}
EXAMPLE 2
---------
/*****
self-tutor example.
This program fills in the "valid" list for
the variable "x" before the initial tutor is
performed. The PDF for this program
should be:
process options=selftutor
parm x valid=(dummyl, dummy2)
end-proc
*****/
#include "taeconf.inp"
#include "parblk.inc"
#include "terminc.inc"
main( )
{
Id vmid, Vm_New( );
CODE Vm_ReadFromTM( );
struct VARIABLE *v;
struct VARIABLE *x;
struct VARIABLE *Vm_Find( );
static TEXT *stringVector[] =>
{"firstValidValue", "secondValidValue",
"thirdValidValue", "lastValidValue");
vmid = Vm_New (P_ABORT);
Vm_ReadFromTM (vmid);
v = Vm_Find (vmid, "_tutor"); /* get _tutor */
if (IVAL(*v,O)) /* if tutor == 1 */
{
/*****
Here: access data base to get valid strings.
In this example, we (instead) hard-code
several strings. After setting the valids,
we initiate dynamic tutor, which to the end
user looks like initial tutor.
*****/
Vm_SetValidString (vmid, "x", 4, stringVector);
Vm_DynTutor (vmid, "", M_FULLPDF);
Vm_ReadFromTM (vmid);
}
/* normal program execution */
x = Vm_Find (vmid, "x");
t_write (SVAL(*x,0), T_STDCC);
}
TCL:
if ($count(p) < 0) write "p has no value"
C:
struct VARIABLE *v;
Id vmid;
vmid = Vm_New (P_ABORT);
Vm_ReadFromTM (vmid);
v = Vm_Find (vmid, "p");
if ((*v).v count < 0)
printf ("p has no value/n");
When executed for self-tutor, the proc receives a V-block with x set to 35 and y set to 17, overriding the default values in the PDF This "priming" feature. is especially powerful when the tutor command appears in a .COMMAND directive of an MDF.