Programming Guide |
Moves the cursor into a field
int sm_gofield(int field_number);int sm_e_gofield(char *field_name, int element);int sm_i_gofield(char *field_name, int occurrence);int sm_n_gofield(char *field_name);int sm_o_gofield(int field_number, int occurrence);
field_name, field_number
- The destination field.
element
- The destination element.
occurrence
- The destination occurrence. If
occurrence
is offscreen, Panther scrolls it into view.
- 0 Success.
sm_gofield
puts the cursor in the first enterable position of the specified field or occurrence, according to its justification. If the field is shiftable, it is reset. If the field has embedded characters, the cursor goes to the nearest position unoccupied by a punctuation character. Use sm_off_gofield to put the cursor elsewhere in the field.When called to position the cursor in a scrolling array,
sm_o_gofield
andsm_i_gofield
return an error if the occurrence number passed exceeds by more than 1 the number of allocated occurrences in the specified array.This function does not immediately trigger field entry, exit, or validation processing. This processing occurs according to the cursor position when control returns to sm_input.
If a field validation function that calls
sm_gofield
is invoked by TAB, Panther executessm_gofield
and moves the cursor to the specified field, then executes the TAB. To prevent this extra tab, the validation function must return non-zero. When non-zero is returned by a validation function, the field'svalided
property is set to 0 (false). In this case, reset the property to 1 (true).
#include <smdefs.h>
/* If the combination of this field and the previous
* one is invalid, go back to the previous for data
* entry. */
int validate(field, data, occur, bits)
int field, occur, bits;
char *data;
{
if (bits & VALIDED)
return 0;
if (!lookup(data, sm_fptr(field - 1)))
{
sm_novalbit(field - 1);
sm_gofield(field - 1);
sm_fquiet_err(0, "Lookup failed - "
"please re-enter both items.");
return 1;
}
return 0;
}