Using Data Import : Using Functions in C/C++ Language Programs : Initializing the Import Process

Initializing the Import Process

To initialize the import process, add the following statement to your program before any calls to Data Import library functions:

stmInitImport (workarea_dir, project_name)

In this call:

project_name - The name of the Rational Statemate project.
workarea_dir - The directory pathname of your workarea in which the specification database is found.

This function returns a STMContextHandle pointer if successful, or NULL if unsuccessful.

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

main( )
{
STMContextHandle *stm_handle;
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);
stm_handle = stmInitImport(dir,name);
if (!stm_handle)
printf ("Init function failed.");
}

 

Note:  
It is recommended that you write the init function in the form shown in the example (stm_handle=...; if(!stm_handle)...;) to ensure that the init function succeeds before continuing.