In file input.h:

int get_menu

(char* option, int showmenu, int lmenu, int smenu,
int err, char* opts, int def, int defval)

Validate input for a simple menu.

Documentation

Validate input for a simple menu.

Displays a long menu (lmenu) once per session (if showmenu), plus whenever the question mark (?) is entered. The prompt is a short version of the long menu (smenu). Options are single characters contained in opts. In case of error, err is prompted. Defaults are handled in the usual way. The selection is returned in option[0].

Parameters:
option - pass a pointer to a single char variable here. On successful exit, the variable will hold the user's option in upper case.
showmenu - controls display of the long menu prompt lmenu. A non-zero value displays lmenu before doing anything else, or when the user types ? to request for help. A zero only displays the lmenu when the user requests for help (unless input flag INF_HELP) is in effect, in which case the function exits and the caller is responsible for processing the help request. Complicated? Yes, it is. Sorry.
lmenu - is the prompt number of the long menu to display. If lmenu is zero, no long menu will be displayed, no matter what the value of showmenu is. The long menu prompt must belong to the current message block.
smenu - is the short prompt number to display. This should give the user their options and little more besides. This prompt should belong to the current message block. It will not be displayed if the value is zero, but please don't do this as it makes things look inelegant.
err - the error prompt to display. As usual, specify zero to disable error printing. You can have an optional %c format specifier in the error prompt. It will be substituted by the character entered by the user.
opts - is a string of upper case characters representing the options available to the user. Leave this empty and the user will only be able to exit this part of the module by using X (which should work everywhere).
def - is the default user prompt (which must belong to the current prompt block). This is usually a short string added to the short menu prompt, and looks like `(Enter=%c)' or `[%c]'. The format specifier gets the value of defval. Use a zero to disable printing of defval where, for instance, the default value is printed by smenu.
defval - is the default user option (in upper case) for when the user presses Enter.
Returns:
Zero if the user bails out with X; one if the process was successful, in which case option is modified to hold the user's selection (or the default value). A value of -1 means that INF_HELP was set and the user pressed `?'.

Alphabetic index



This page was generated with the help of DOC++.