Using Dataport Functions : Using Functions in C Language Programs : Initializing the Retrieval Process

Initializing the Retrieval Process

To initialize the retrieval process, add the following statement to your program before any calls to Dataport library functions:

stm_init_uad (proj_name, w_area, trans_mode, &status)

In this call:

proj_name - The name of the Rational Statemate project containing the information of interest.
w_area - The directory pathname of your workarea in which the specification database is found.
trans_mode (transaction on mode) - The transaction on mode. This specifies the manner in which you want to handle database transactions, using self_transaction or automatic_transaction modes.

This function returns true if successful, or false if unsuccessful. If unsuccessful, check the status argument for the reason the function failed.

Note: The stm_init_uad function automatically changes the current directory to the workarea directory. Therefore, all references to files inside the program have to take this into account. Also, when the program terminates, it does not return to the original directory.

The following example shows how to initialize the retrieval process in a C program. In this example, you are prompted for the name of the project to open.

main( )
{
int status, success;
char name[32];
char dir[30];
printf ("Enter name of Statemate project: ");
scanf ("%s", name);
printf ("Enter directory pathname
for your Workarea: ");
scanf ("%s", dir);
success =
stm_init_uad (name, dir, automatic_transaction,
&status);
if (!success)
printf ("Init function failed.
Reason: status code %d", status);
}
Note:  
It is recommended that you write the init function in the form shown in the example (success=...; if(!success)...;) to ensure that the init function succeeds before continuing.