Sample Program : Program Description : Creating the Lists

Creating the Lists
void activity boxes()

This primary function creates a list of activities. The list is composed of a specified activity together with its subactivities. You are prompted for the parent activity.

{
char ac_name[32];
stm_id ac_id;
stm_list ac_list,acs_list;
 

ac_name holds the name of the activity., ac_id holds the ID number of the activity, and ac_list and acs_list hold the list of activities.

printf ("\n enter activity name: ");
GET_STR (ac_name);
ac_id = stm_r_ac (ac_name, &status);
if (status!=stm_success)
{
printf ("illegal activity name");
return;
}

The element ID that corresponds to the element name is retrieved. The status check determines whether the retrieval was successful. If the activity name is not unique or if it is incorrect, an error message is printed and the function is aborted.

ac_list = stm_list_create (ac_id, end_of_list, &status);

 

This statement creates a list of the single activity of interest. This list is then used as an input parameter for the routine stm_r_ac_physical_sub_of_ac.

acs_list = stm_r_ac_physical_sub_of_ac (ac_list, &status);

 

This statement creates a list of all the subactivities for the input activity list (which, in this case, contains only a single activity).

if (status != stm_success)
{
printf ("error during execution");
return;
}

The status of the operation is checked for success (in this case, the check is redundant). An error could be caused if the activity in ac_list is deleted from the database by some other process while the sample C program is being executed. This situation can occur when the entire program is performed under more than one transaction.

acs_list = stm_list_union (ac_list, acs_list, &status);

This statement merges the two lists that contain the parent activity and its subactivities.

activities_info(acs_list);
}

The last statement of this function calls the function activities_info, which retrieves information for each element in a list of activities.