Listing 4

#include "empl.h"       /* Generated by a tool */
#include "sml.h"        /* Library defines, etc. NOT SHOWN */

main(argc, argv)
    int argc;
    char *argv[];
{

    int sid,                     /* Screen identifier             */
       status;
    char *data[EMPL_MAX_FIELDS]; /* Pointers for accessing fields */

    init_sml(1);                 /* Initialize the library */

    /*
     * Open a screen
    */
    if ((sid=open_form(argv[1])) == SML_ERROR){
       fprintf(stderr, "Error opening %s\n", argv[1]);
       exit(1);
    }

    /*
     * Display it. The 0,0 is a row, columns offset on the current
     * window where the screen is displayed.
    */
    if(display_form(sid, 0, 0) == SML_ERROR){
       fprintf(stderr, "Error displaying %s\n", argv[1]);
       exit(1);
    }

    /* Set up the custom edit function */
    set_edit(sid, FO_EMPL_AGE, valid_age);

    /* Get the data                    */
    do{
       status = get_screen(sid, data);
       /*
        * Do something with the data. Write it, print it,
        * whatever...
       */
    }while(status != SML_EXIT); /* Loop until the user is done...*/

    cleanup_sml();
}