Form is distributed as an executable program and as an object file in
a library. You can run the executable program when you require no extra editing
of data fields; it is sufficient for most data entry screens. The object file
is provided so you can add extra C programming that is executed during the data
entry session.
To make a version of form with your added C code, you must provide a C program that defines at least two procedures, main and user_edit. When you compile and link your C program with the C/Base library, you create an executable version of form with your C code.
The simplest user edit routine is shown below. In fact, this routine produces the standard executable version of form.
#include <stdio.h>
main (argc, argv)
int argc;
char *argv[];
{
form (argc, argv);
exit (0);
}
/* default edit routine for forms */
char *
user_edit ()
{
return (NULL);
}
You can compile this program as follows (your compiler may require additional options):
cl -c -AL -Ic:\cbase\include form.c
cl /F 5000 /Fe..\bin\form form.obj /link /NOE c:\cbase\lib\libcbase.lib
Before you can compile a C program the environment variables INCLUDE, TMP, and LIB must be set. Refer to Appendix A, Compiling C Programs in this manual, and the Microsoft Compiler Users Guide and Reference Manual for more information on compiling C programs. (For information on compiling under Windows refer to section 5.4, Compiling with C/Base Utilities in the C/Base & C/Books Installation Manual for DOS/Windows.)
Your main procedure should pass its arguments (argc and argv) to the form function, which is contained in the \cbase\lib\libcbase.lib object library. The form function does not return; when the operator presses the EXIT <F8> key, form calls exit () to terminate the program.
Your user_edit function must always return either a pointer to an error message if it discovers an error or return a NULL pointer. If user_edit returns a pointer to an error message, form displays the error message on the screen and the leaves the cursor at the current entry field. If user_edit returns a NULL pointer, no error has occurred, and form continues on to the next entry field.
When you write your own user edit routine, you will replace the user_edit function to provide additional editing, and compile and place it in a file with a unique name. The new program could then be used just as form has been to provide additional forms editing features.