home *** CD-ROM | disk | FTP | other *** search
-
- ^bMulti-Field Input Functions^b
-
- Three functions are needed to process multi-field formatted input from
- windows: winpbeg(), winpdef(), and winpread(). The winpbeg() function
- marks the start of an input form. The winpdef() function defines an
- input field and is called for each input field to be defined. The
- winpread() function marks the end of the input form and processes all
- defined fields. The formatted input capabilities are much like those of
- the inputsf() and winputsf() functions. The major difference is that
- with the winpbeg()/winpdef()/winpread() combination, you can edit back
- and forth between fields before finally accepting the input.
-
- For every input field you want to define, you must call winpdef(). This
- will allocate memory to hold the input record information. The first two
- parameters, wrow and wcol, specify where in the active window the field
- will be loaded.
-
- The next parameter, str, is the address of the string buffer to receive
- the input data. The edited string will be terminated with a '\0'. This
- means if your format string is "AAAAA", your receiving field must be
- string[6] to hold the terminating '\0'. You can edit numeric
- information as well. There are 4 conversion functions to convert numbers
- to/from CXL fields:
-
- cvtic() - convert integer to CXL field string
- cvtci() - convert CXL field string to integer
- cvtfc() - convert real number to CXL field string
- cvtcf() - convert CXL field string to real number
-
- The next parameter, format, is the input field format string. It
- controls how each character is input and how large the input field will
- be. It consists of 1 or more format characters, and may have displayed
- text in between any of the format control characters. You may use
- spaces in between the format control characters for readability. Valid
- format control characters are listed in the "Formatted Keyboard Input
- Functions" section. The case of the format control characters must be
- as shown. You can also specify a decimal point in the field. Format
- strings for winpdef() are just like those of inputsf() and winputsf()
- except there are no command toggles.
-
- The next parameter in the winpdef() function is fconv. These are
- similar to the command toggles of inputsf() and winputsf() except that
- the fconv character applies conversion to the whole field. Valid fconv
- characters are:
-
- ^b0^b - apply no conversion
- ^b'L'^b - convert letters to lowercase
- ^b'M'^b - convert letters to mixed upper & lowercase
- ^b'P'^b - password field (do not echo characters)
- ^b'U'^b - convert letters to uppercase
- ^b'9'^b - numeric field (right justify, space fill to the left of
- the decimal; and left justify, zero fill to the right of
- the decimal.
-
- After the fconv parameter comes the mode parameter. This parameter
- allows you to specify if the input field is going to create new data or
- update old data. If the mode parameter is 0, then the input field
- will be used for entering new data. If the mode parameter is nonzero,
- then the input field will be used to update the old data contained in
- the str parameter. If you specify 2 for mode, the cursor will appear
- at the end of the line and if an editing key is pressed first, the field
- will be used for updating, otherwise the field will be used to create
- new information. If you do choose to update, then the length of the
- input str will be adjusted to the field size either by truncation or
- padding with spaces.
-
- The next parameter in the winpdef() function is validate. This
- parameter is the address of an optional user validation/modification
- function. If no validation function is to be used, then specify NULL.
- Your user validation/modification function must be declared like:
-
- int func(char *str);
-
- where str is the address of the input field that will be passed to it.
- Once your user function has the address of the input field, you can
- validate and/or modify the input field. Your function can also display
- an error message, sound a bell, or just about anything. When your
- function is done, it must return 0 for no error, or the position in the
- field where the error occurred (starting with 1).
-
- The final parameter to winpdef(), help, is the address of the help
- category string to assign to this menu item. This is useful if you are
- using the context-sensitive help system and you want to assign a
- different help category to each field. If you do not need to use this
- feature, specify NULL for this parameter.
-
- The winpdef() function will return one of the following values:
-
- ^bW_NOERROR^b - no error
- ^bW_NOACTIVE^b - no active window
- ^bW_INVCOORD^b - invalid coordinates
- ^bW_ALLOCERR^b - memory allocation error
- ^bW_NOFRMBEG^b - no begin of form specified (winpbeg() not called)
- ^bW_INVFORMT^b - invalid format string (syntax error)
-
- Once you have defined all input fields with winpdef(), you call
- winpread() to process them. The user is allowed to move around and edit
- all of the fields. The input fields are validated on the fly and after
- entering the last field. Valid editing keys are listed in Appendix E.
-
- After the winpread() function returns, all fields defined with winpdef()
- will be cleared. The receiving strings of all defined fields will now
- contain the data entered. If Escape checking was on and [Esc] was
- pressed, then all receiving strings will contain the values they held
- before winpread() was called and W_ESCPRESS will be returned.
-
- The general structure for defining input fields looks like:
-
- winpbeg(...);
- winpdef(...);
- winpdef(...);
- winpdef(...);
- winpread();
-
- !seealso cxlappn.ngo:"AppendixE"
-