Next: trial_read_window()
Up: Writing the Standard Panel
Previous: trial_field_manager()
  Contents
trial_init()
This procedure is designed to be called by trial_field_manager().
The code here should prepare and initialize a data structure to hold the information
read from and written to the new window. This means that for every text field
or settings item on the window, there must be an element of the data structure which
will contain the value of the window item.
In the simple example which we
have been developing the data structure simply consists of an array of doubles
to hold the values of the varb_value text fields and an integer to indicate the
selected choice from the settings panel.
double *new_varb_value;
int trial_choice;
int
trial_init()
{
int i,n_varb;
char *calloc();
n_varb = *((int *) pm(GET, Traj_Ds_Object, Varb_Dim, NULL));
/* free up previous storage, if any */
if (trial_varb_value != NULL) cfree((char *) trial_varb_value);
/* create storage for operations, and set initial values */
trial_varb_value = (double *) calloc(n_varb,sizeof(double));
if (trial_varb_value == NULL)
{
system_mess_proc(1,"trial_init: Memory Allocation failed.");
return(-1);
}
/* initialize the values for the text fields */
for (i=0; i<n_varb; i++)
{
trial_varb_value[i] = 0.0;
}
/* reset the setting to choice 0 */
trial_choice = 0;
return(0);
}
root
1998-11-02