Copies the contents of a fieldint sm_getfield(char *buffer, int field_number);int sm_e_getfield(char *buffer, char *field_name, int element);int sm_i_getfield(char *buffer, char *field_name, int occurrence);int sm_n_getfield(char *buffer, char *field_name);int sm_o_getfield(char *buffer, int field_number, int occurrence);
- On return, contains the data copied from the specified field.
- The field to copy, where
field_namecan be the name of a field or group.
- The element to copy.
- The occurrence to copy.
sm_getfieldcopies data from the specified field or occurrence to
buffer. Panther omits leading blanks from right justified fields and trailing blanks from other fields If you specify the field by name and the field is not on the screen, Panther looks for the corresponding LDB entry. If you call the function during screen entry processing, Panther first checks the LDB for an entry if ENTEXT_OPTION is set to
Make sure that
bufferis large enough to receive the field's contents—at least one greater than the field's maximum length.
If you call
sm_n_getfieldon a radio button group that allows one selection,
buffergets the group occurrence number of the selected item. For example, the radio button group
ratinghas the third occurrence,
Given this selection, the following call to
sm_n_getfieldputs the string
buffer:retvar = sm_n_getfield(buffer, "rating");
To get selections in a group that allows multiple selections—for example a group of check box widgets—issue successive calls to either
sm_o_getfield. For example, the
genrecheck box group has occurrences 1, 3, and 4 selected:
Panther sees a group's value as an array whose elements contain the offsets of the selected items. Thus, Panther stores the selections in
genreas follows:genre = "1"
genre = "3"
genre = "4"
genre = " "
The following code gets the selections in
genrethrough successive calls to
sm_i_getfield:int len, grp_occ, num_occs;
/* get number of selections in group "genre" */
num_occs = sm_prop_get_int(sm_prop_id("genre"),
/* get offset of selections */
for (grp_occ = 1; grp_occ <= num_occs; grp_oc++)
len = sm_i_getfield(select_val, "genre", grp_occ);
Each call to
sm_i_getfieldgets the next
valselection in the group and puts its offset into
select_val. For instance, when
sm_i_getfieldgets the second-selected item in
genreand puts its offset value, 3 (
/* Save the contents of the "rank" field in a buffer
* of the proper size. */
size = sm_n_dlength("rank");
if ((save_rank = malloc(size + 1)) == NULL)
sm_dblval, sm_fptr, sm_intval, sm_lngval, sm_putfield