Using Dataport Functions : Dataport Function Calls

Dataport Function Calls

Dataport function calls can appear anywhere in your program once an initialization procedure is performed. Here are some examples of valid function calls.

In this example, the state named S1 is retrieved from the database and the variable state_id is assigned to it. The state’s ID is retrieved; ID is a value that Rational Statemate uses to identify each element in the database. The state_id can be used later in other function calls.

state_id = stm_r_st ("S1", &status);

Function calls are frequently used in sequence. For example, the ID for state S1 in this function call has already been retrieved. The sample call retrieves the synonym of this state.

synonym = stm_r_st_synonym (state_id, &status);

This function creates a list (which contains the state S1), assigns it to the variable state_list, then extracts the substates of S1.

state_list = stm_list_create (state_id,
end_of_list, &status);
sub_st = stm_r_st_physical_sub_of_st (state_list,
&status);
 
for (s = (stm_id) stm_list_first_element(
sub_st, &status);
status == stm_success;
s = (stm_id) stm_list_next_element(
sub_st, &status)
)

Prints a list of all substates of state S1.

printf ("\n %s", stm_r_st_name (s, &status));

Refer to Sample Program for an example of how to call Dataport functions in a C program.