3.3.4 U_ADD



Form calls the user edit routine with the type parameter equal to U_ADD when form enters ADD mode. All the other parameters passed to the user edit routine are NULL. Your user edit routine is called when the operator presses the ADD key and when form automatically enters the ADD mode after a STORE.

The user edit routine is called with U_ADD before the blank form is displayed; it announces that the user wants to start adding a new record. The user edit routine should not assume that the record that the operator enters will always be stored in the RMSfile. The operator can leave ADD mode if all the input fields are blank by pressing another function key, or the operator can leave ADD mode at any time by pressing CANCEL. Thus, the user edit routine should not take any action that assumes a record will be stored in the RMSfile. This action should be deferred until U_PREPARE (the STORE key is pushed).

If you want to swrite into a field when form goes into ADD mode, you must do the swrite during U_BEGINFORM rather than U_ADD, since during U_ADD the form has not yet been displayed. See the swrite function described at the end of this chapter.