Programming Guide



sm_get_bundle_occur_count

Counts the number of occurrences in a data item

int sm_get_bundle_occur_count(char * bundle_name, int item_no);

bundle_name
The name of the bundle. Supply NULL or empty string to specify the unnamed bundle.

item_no
The bundle offset of the item whose occurrences you want to count. Each data item is identified by its offset within the bundle, where the first data item has an offset value of 1.

Returns

Description

sm_get_bundle_occur_count counts the number of occurrences in the specified data item. Use this function to get the number of occurrences in a data item. This lets you supply the correct argument to sm_get_bundle_data to read the entire contents of the item into a buffer. You can also use the function's return value to set a counter for successive reads from this buffer into a target field.

Example

/* read data occurrences from a bundle data item
into a field
*/
char *occur_data, array_data;
int num_occurs, emp_name_occur;
emp_name_occurs = 1;

/*count the number of occurrences in the data item */
num_occurs = sm_get_bundle_occur_count("myBundle", 1);

/*get item data and put into field*/
for (occur = 1;occur <= num_occurs;occur++, emp_name_occur++)
sm_i_putfield
("emp_names",
emp_name_occur,
sm_get_bundle_data("myBundle",1,occur);

See Also

sm_get_bundle_data