Programming Guide |
Gets the length of a field's contents
int sm_dlength(int field_number);int sm_e_dlength(char *field_name, int element);int sm_i_dlength(char *field_name, int occurrence);int sm_n_dlength(char *field_name);int sm_o_dlength(int field_number, int occurrence);
field_name
field_number
- The field with the data to evaluate.
element
- The element in
field_name
with the data to evaluate.occurrence
- The occurrence in the field with the data to evaluate.
- 0 Length of field contents.
sm_dlength
returns the length of the data in the specified field or occurrence of a field. The length includes any data that is shifted offscreen and therefore out of view. The length excludes leading blanks in right-justified fields, and trailing blanks in left-justified fields.
#include <smdefs.h>
/* Save the contents of the "rank" field in a buffer
* of the proper size. */
char *save_rank;
if ((save_rank = malloc(sm_n_dlength("rank") + 1)) == NULL)
{
report_error("malloc error.");
}
else
{
sm_n_getfield(save_rank, "rank");
}