home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 19 / CD_ASCQ_19_010295.iso / dos / prg / c / cwl30 / cwl3docs / form.doc next >
Text File  |  1994-10-15  |  227KB  |  6,212 lines

  1.                     THE C WINDOW LIBRARY - DATA FORMS
  2.  
  3.            (c) Copyright P. A. McKenzie 1990, 1991, 1992, 1993
  4.                            All Rights Reserved
  5.  
  6.                               Version 1.5
  7.  
  8.  
  9.                     T A B L E   O F   C O N T E N T S
  10.  
  11.        INPUT FORMS.................................................. 1
  12.                Form Manager ........................................ 1
  13.  
  14.  
  15.        INITIALIZING THE FORM LIBRARY ............................... 2
  16.                FormInitializeSystem() .............................. 2
  17.                FormInitializeFloat() ............................... 2
  18.  
  19.  
  20.        CREATING FIELD ENTRIES IN A FORM ............................ 3
  21.        The FIELD_ENTRY structure ................................... 3
  22.                Field Types ......................................... 4
  23.                Field Row and Column ................................ 5
  24.                Field Mask .......................................... 6
  25.                Field Fill Character ................................ 6
  26.                Field Minimum Characters............................. 6
  27.                Field Maximum Width ................................. 6
  28.                Field Options ....................................... 6
  29.                Field Starting Input Position ....................... 9
  30.                Field Attributes .................................... 9
  31.                Field Regular Expression ............................ 9
  32.                Alternate Methods of Creating FIELD_ENTRY's ......... 10
  33.  
  34.        FormInitialize() ............................................ 13
  35.                Form Options ........................................ 13
  36.                Field Errors ........................................ 16
  37.  
  38.        Setting Number of Decimal Places in a field with
  39.        FormSetFieldDecimal() ....................................... 16
  40.  
  41.        SPECIAL DATA TYPES .......................................... 19
  42.                The CWL_LIST special field .......................... 19
  43.                     Retrieving the list selection .................. 21
  44.  
  45.                The CWL_TOGGLE special field ........................ 21
  46.                     Retrieving the toggle selection ................ 23
  47.  
  48.                The CWL_SUBFORM and CWL_VSUBFORM special fields ..... 23
  49.  
  50.                CWL_BUTTON fields ................................... 25
  51.  
  52.                CWL_RADIO Fields and the RADIO_ENTRY structure ...... 30
  53.                     Deactivating and Activating Radio Entries....... 32
  54.                     Retrieving the Radio selection ................. 33
  55.  
  56.                CWL_CHECKBOX Fields and the CHECKBOX_ENTRY structure. 34
  57.                     Deactivating and Activating Checkbox Entries ... 37
  58.                     Retrieving the checkbox selection .............. 38
  59.  
  60.        GETTING INPUT FROM A FORM ................................... 40
  61.                FormGetInput() ...................................... 41
  62.                Virtual Form Scrolling .............................. 42
  63.                Editing Input ....................................... 42
  64.                Changing the Editing Key definitions globally using the
  65.                CWLform_edit_key table .............................. 45
  66.  
  67.        Page i            The C Window Library                     Page i
  68.  
  69.                    T A B L E   O F   C O N T E N T S
  70.  
  71.                Changing the Editing Key definitions using
  72.                FormAssignFieldKeys() ............................... 45
  73.                Traversing fields and the FORM_HIGHLIGHT option ....  47
  74.  
  75.  
  76.        ASSIGNING VALUES TO AND RETRIEVING VALUES FROM A FORM ....... 48
  77.                FormSetFieldVariable() .............................. 48
  78.                Placing input with FormPutFieldData() ............... 49
  79.                Retrieving Input with FormGetFieldData() ............ 50
  80.                Pre-filling a form with default data ................ 51
  81.                Setting up array of strings using Allocate2DArray() . 51
  82.                Freeing a two dimensional array using Free2DArray() . 53
  83.                Using FormInitializeFieldData() ..................... 53
  84.  
  85.  
  86.        SETTING FIELD OPTIONS ....................................... 56
  87.                FormSetFieldOptions() ............................... 56
  88.  
  89.  
  90.        SETTING FORM OPTIONS ........................................ 58
  91.                FormSetOptions() .................................... 58
  92.  
  93.  
  94.        WRITING VALUES TO THE FIELD BUFFER .......................... 60
  95.                FormWriteFieldValue() ............................... 60
  96.  
  97.  
  98.        SETTING FIELD PRE-FUNCTIONS ................................. 61
  99.                Defining global pre-functions ....................... 61
  100.                Defining field specific pre-functions ............... 61
  101.                Return Values To The Form manager ................... 62
  102.  
  103.  
  104.        SETTING FIELD POST-FUNCTIONS ................................ 66
  105.                Defining global post-functions ...................... 66
  106.                Defining field specific post-functions .............. 66
  107.                Return Values To The Form manager ................... 66
  108.  
  109.  
  110.        UNDEFINED KEYSTROKE PROCESSING .............................. 69
  111.                CWLform_undef_fkey_func and CWLform_undef_akey_func
  112.                   function pointers ................................ 69
  113.                Specifying when to call an undefined key function is a
  114.                   Regular Expression ............................... 70
  115.                Return Values To The Form Manager ................... 70
  116.  
  117.  
  118.        PROCESSING EDITING ERRORS ................................... 73
  119.                Minimum Number of Characters Checking ............... 73
  120.                Overriding Error Checking for Minimum Number
  121.                  of Characters ..................................... 73
  122.                Checking if Field Characters Match Regular Expression 74
  123.                Calling a User Written Function when errors occur ... 75
  124.                Return Values for User Written Function ............. 75
  125.  
  126.  
  127.        Page ii           The C Window Library                     Page ii
  128.  
  129.                    T A B L E   O F   C O N T E N T S
  130.  
  131.        USER DEFINED ERROR CHECKING ................................. 78
  132.                FormSetFieldValidateFunction() ...................... 78
  133.                Return Values for the user defined error function ... 78
  134.                FormCheckFieldRange() ............................... 80
  135.  
  136.  
  137.        CLEARING A FORM ............................................. 83
  138.                FormClear() ......................................... 83
  139.  
  140.  
  141.        EXITING A FORM .............................................. 84
  142.                FormSetExitFunction() ............................... 84
  143.  
  144.  
  145.        DISPOSING OF A FORM ......................................... 88
  146.                FormClose() ......................................... 88
  147.  
  148.        USING A MOUSE ............................................... 89
  149.  
  150.        MISCELLANEOUS FORM FUNCTIONS ................................ 89
  151.                FormGetFieldString() ................................ 89
  152.                FormGetFieldRowCol() ................................ 89
  153.  
  154.  
  155.        FORM MACROS ................................................. 90
  156.  
  157.        INDEX ....................................................... 97
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.        Page iii          The C Window Library                     Page iii
  191.  
  192.                                INPUT FORMS
  193.                                -----------
  194.  
  195.        A data entry form can be defined as a collection of input fields
  196.        that are combined in a window.  By using data entry forms, it
  197.        makes it easier to collect input.  Without data entry forms, the
  198.        only way to get input is to call a series of WindowGet...()
  199.        functions.  Although this is possible, it can be very cumbersome
  200.        to manage these fields if they are not in some way logically
  201.        tied together, even though each field is independent of each
  202.        other.  For example, if you want to advance to the next field by
  203.        using the down arrow key on the keyboard, you would have to set
  204.        up an undefined keystroke function that tests for the down
  205.        arrow, and then tell the input manager to terminate the input.
  206.        You would then tell your program to advance to the next field
  207.        and start the input process over again for the new field.
  208.  
  209.        By using forms, The C Data Forms library makes it much easier
  210.        for the programmer to set up a data entry form, without worrying
  211.        about the details of traversing from field to field, as the
  212.        above example has detailed.
  213.  
  214.        The forms in The C Window Library also allow other options.
  215.        Here are a few of them:
  216.  
  217.         * You can have simple windowed forms or have forms that are
  218.        larger than the physical screen (virtual forms).
  219.  
  220.         * You have pre and post functions on the field level as well as
  221.           the global level (pre-post function is called for all
  222.           fields).
  223.  
  224.         * Fields can have a user defined error function tied to them.
  225.  
  226.         * Fields can be highlighted as the input cursor is moved from
  227.           field to field, or can remain the same color regardless of
  228.           where the input cursor is.
  229.  
  230.         * Automatic conversion of a field to the right data type, and
  231.           then the converted value can be assigned to any variable you
  232.           choose.
  233.  
  234.         * Choice lists, toggle fields, subforms, radio, button, and
  235.           checkbox fields are supported.
  236.  
  237.         * You can retrieve or update a field at any time, even when the
  238.           form is not the current input form.
  239.  
  240.         The above are just some of the features of The C Data Forms
  241.         Library's form functions.
  242.  
  243.  
  244.        Form Manager
  245.        ------------
  246.  
  247.        The form manager is the set of functions internal in The C Data
  248.        Forms Library that handle the grunt work of processing a form.
  249.  
  250.          Page 1          The C Window Library                 Page 1
  251.  
  252.                          INITIALIZING THE FORM LIBRARY
  253.                          -----------------------------
  254.  
  255.        This section defines the preliminaries when setting up your
  256.        program to handle forms.
  257.  
  258.        FormInitializeSystem()
  259.        ----------------------
  260.  
  261.        Before you call any form functions, you must call the
  262.        FormInitializeSystem() function.  This function sets up global
  263.        variables used by the form manager.  If this function is not
  264.        called, the form manager may act unpredictably, leading to
  265.        undesired effects.  Here is the prototype:
  266.  
  267.                 void FormInitializeSystem(void)
  268.  
  269.        There are no arguments or a return value.  This function MUST be
  270.        called after WindowInitializeSystem() to take effect.
  271.  
  272.  
  273.         #include "cwlwin.h"         /* This include is needed for form
  274.                                        functions */
  275.  
  276.         main()
  277.         {
  278.           WindowInitializeSystem();
  279.           FormInitializeSystem(); /* Note how FormInitializeSystem() is
  280.                                      called after
  281.                                      WindowInitializeSystem() */
  282.         }
  283.  
  284.  
  285.        FormInitializeFloat()
  286.        ---------------------
  287.  
  288.        If you are using any floating point values in your form i.e.
  289.        double and float data types, you must call the
  290.        FormInitializeFloat() function after you call
  291.        FormInitializeSystem().  This function allows the floating point
  292.        library to be loaded into your program when the program is
  293.        linked.  The C Window Library will not use any floating point
  294.        functions unless FormInitializeFloat() is called.  Here is the
  295.        prototype and a small example:
  296.  
  297.        Prototype:
  298.        void FormInitializeFloat(void);
  299.  
  300.        Example:
  301.        #include "cwlwin.h"
  302.        main()
  303.        {
  304.           WindowInitializeSystem();
  305.           FormInitializeSystem();
  306.           FormInitializeFloat();    /* Now C Data Forms knows to use
  307.                                         floating point routines */
  308.        }
  309.  
  310.          Page 2          The C Window Library                 Page 2
  311.  
  312.                        CREATING FIELD ENTRIES IN A FORM
  313.                        --------------------------------
  314.  
  315.        The FIELD_ENTRY structure
  316.        -------------------------
  317.  
  318.        The most important thing to learn when creating a form is how to
  319.        set up the array of FIELD_ENTRY's.  These FIELD_ENTRY's define
  320.        each field of the form, the field size, location, options,
  321.        regular expression, mask, minimum visible width of the field
  322.        (this allows left and right scrolling of long fields).
  323.  
  324.        Here is the description of a FIELD_ENTRY structure:
  325.  
  326.  
  327.        int      type  --  This defines the fields data type (integer,
  328.                           double, etc.)
  329.  
  330.        unsigned row   --  This defines the row in the window (or
  331.                           virtual window) of where the field is
  332.                           located.
  333.  
  334.        unsigned col   --  This defines the column in the window (or
  335.                           virtual window) of where the field is
  336.                           located.
  337.  
  338.        char     *mask --  This is the input mask to use for the field.
  339.                           This mask is the same as the masks defined in
  340.                           the WindowGet...() family of functions.
  341.  
  342.        int      fillchar -- This is the character to use for unfilled
  343.                             input positions in the field.
  344.  
  345.        int      minchars -- This is the minimum number of characters to
  346.                             accept in a field.
  347.  
  348.        int      maxwidth -- This is the visible width of the field.  If
  349.                             the input goes beyond the right edge of the
  350.                             visible width of the field, the input is
  351.                             scrolled.
  352.  
  353.        unsigned long options -- These are the field options described
  354.                             for the field.
  355.  
  356.        int      startpos -- This is the starting position in the field
  357.                             to place the input cursor.  Usually this is
  358.                             position 1.
  359.  
  360.        int      attr    -- Color attribute to use for the field.
  361.  
  362.        char     *regexp -- Regular expression used for the input field.
  363.  
  364.  
  365.        An array of these FIELD_ENTRY's is needed to build the form.
  366.        The order of the array elements determine the order of
  367.        processing for each field.  Here is a simple way of creating an
  368.        array of FIELD_ENTRY's:
  369.  
  370.          Page 3          The C Window Library                 Page 3
  371.  
  372.        #include "cwlwin.h"
  373.        #define NORM  CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  374.  
  375.  
  376.        FIELD_ENTRY field_array[] =
  377.  
  378.  
  379.                /* define first field entry */
  380.  
  381.                {CWL_INTEGER,   /* field type */
  382.                 0,   /* field row in window (or virtual window) */
  383.                 20,   /* field column in window (or virtual window) */
  384.                 "___",   /* field mask */
  385.                 '_',   /* fill character to use */
  386.                 1,   /* minimum characters to accept */
  387.                 3,   /* maximum field width */
  388.                 FIELD_RJUSTIFY,   /* field option to use */
  389.                 0,   /* starting position */
  390.                 NORM,   /* field attribute */
  391.                "3[0-9]",   /* regular expression to use */
  392.  
  393.                /* Now define other field entries */
  394.  
  395.        CWL_STRING, 1, 19, "__________", '_', 0, 10,
  396.                    NO_FIELD_OPTIONS,0,NORM, "10.",
  397.        CWL_INTEGER,2, 19, "__", '_', 2, 2, NO_FIELD_OPTIONS, 0,NORM,
  398.               "2[0-9]",
  399.        CWL_DOUBLE,3, 19, "_______",'_',1,7,
  400.                  FIELD_COMMA | FIELD_LJUSTIFY,0, NORM,"7[0-9/.]",
  401.        CWL_CHAR, 4, 19, "_", '_', 1, 1, FIELD_UPPERCASE, 0,
  402.                  NORM, "[YyNn]",
  403.  
  404.        /* Now terminate the field array */
  405.        FIELDEND};
  406.  
  407.        The above example creates an array of FIELD_ENTRY's called
  408.        field_array.  There are five field entries in the field_array
  409.        array.  Note that the array is terminated with a FIELDEND field
  410.        type.  The above method of initializing an array of
  411.        FIELD_ENTRY's globally is just one way to create the array of
  412.        FIELD_ENTRY's.  There are other ways of creating an array of
  413.        FIELD_ENTRY's by making use of function calls.  These methods
  414.        will be discussed later.
  415.  
  416.  
  417.        Field Types
  418.        -----------
  419.  
  420.        The first member in the first entry is the constant CWL_INTEGER.
  421.        This denotes the type of the data that will be entered in this
  422.        field.  This also tells the form manager what type of conversion
  423.        will be required when converting the input.  When the user
  424.        enters the input, the input is in string form, so conversion is
  425.        necessary.  A list of the constants used here and their
  426.        definitions is as follows:
  427.  
  428.  
  429.  
  430.          Page 4          The C Window Library                 Page 4
  431.  
  432.            Integer data types:
  433.  
  434.                              C language
  435.            Constant          data type
  436.            --------          ----------
  437.            CWL_INTEGER       int
  438.            CWL_UINTEGER      unsigned int
  439.            CWL_LINTEGER      long
  440.            CWL_ULINTEGER     unsigned long
  441.            CWL_CHAR          char
  442.  
  443.  
  444.            String data types:
  445.  
  446.                              C language
  447.            Constant          data type
  448.            --------          ------------
  449.            CWL_STRING        char array[]
  450.  
  451.  
  452.  
  453.            Floating point data types:
  454.  
  455.                              C language
  456.            Constant          data type
  457.            --------          ----------
  458.            CWL_DOUBLE        double
  459.            CWL_FLOAT         float
  460.  
  461.  
  462.            Special data type:
  463.  
  464.            Constant
  465.            --------
  466.            FIELDEND
  467.            CWL_LIST
  468.            CWL_SUBFORM
  469.            CWL_VSUBFORM
  470.            CWL_TOGGLE
  471.            CWL_RADIO
  472.            CWL_CHECKBOX
  473.            CWL_BUTTON
  474.  
  475.        The special data type FIELDEND is used to terminate the array of
  476.        fields.  You MUST use this constant as the last field type, or
  477.        the form manager will not know where the last field is.  The
  478.        other special data types will be discussed later in this
  479.        section.
  480.  
  481.  
  482.  
  483.        Field Row and Column
  484.        --------------------
  485.  
  486.        The second and third members of the first entry is the row and
  487.        column position number of where to place the field.  Remember
  488.        that this position can either be in a window or a virtual
  489.        window.
  490.  
  491.  
  492.          Page 5          The C Window Library                 Page 5
  493.  
  494.        Field Mask
  495.        ----------
  496.  
  497.        The fourth member is the field mask to use for the field.  This
  498.        mask follows the same rules as input masks for the
  499.        WindowGetMask...() family of functions.  The maximum number of
  500.        characters in a mask string is 255 characters.  This includes
  501.        input and non-input positions in the mask.  If you want to
  502.        increase this number, you will have to change the constant
  503.        MAXFIELDSIZE defined in cwlwin.h to whatever number you desire
  504.        plus 1 (the extra character is for the null terminator).  Then
  505.        you must recompile The C Window Library using this new value.
  506.  
  507.  
  508.        Field Fill Character
  509.        --------------------
  510.  
  511.        The fifth member is the fill character to use for empty input
  512.        positions in the field.  In our example the fill character is
  513.        the underscore ('_').
  514.  
  515.  
  516.  
  517.        Field Minimum Characters
  518.        ------------------------
  519.  
  520.        The sixth member is the minimum number of characters to accept
  521.        for this field.  Our example says you must enter at least 1
  522.        character in the first field.  You can override the field
  523.        minimum by using the FIELD_OVERRIDE_FORWARD and the
  524.        FIELD_OVERRIDE_BACKWARD field options defined below.
  525.  
  526.  
  527.  
  528.        Field Maximum Width
  529.        -------------------
  530.  
  531.        The seventh member tells us the maximum visible width of the
  532.        field.  Our example shows that the visible width should be 3
  533.        characters.
  534.  
  535.  
  536.  
  537.        Field Options
  538.        -------------
  539.  
  540.        The eighth member are the field options used on the field.  Here
  541.        are a list of the field options available:
  542.  
  543.  
  544.        FIELD_UPPERCASE - Characters entered in the field are
  545.                          automatically converted to upper case if lower
  546.                          case characters are entered.
  547.  
  548.        FIELD_LOWERCASE - Characters entered in the field are
  549.                          automatically converted to lower case if upper
  550.                          case characters are entered.
  551.  
  552.          Page 6          The C Window Library                 Page 6
  553.  
  554.        FIELD_ENHANCEDKEY - Field can recognize and distinguish between
  555.                            extra keys on extended keyboard (i.e.  F11,
  556.                            F12, dedicated cursor keys, etc.) and the
  557.                            normal keys.
  558.  
  559.        FIELD_CHECKREGEXP - Each character in the field will be checked
  560.                            against the field's regular expression.
  561.                            This check is done when the user wants to
  562.                            accept the input.
  563.  
  564.        FIELD_CHECKSPACES - Spaces will be counted as valid characters
  565.                            when the form manager checks if the minimum
  566.                            number of characters has been entered.
  567.  
  568.        FIELD_AUTORETURN - The field is automatically accepted when the
  569.                           last input position is filled with a
  570.                           character.
  571.  
  572.        FIELD_CHECKREGEXP_IGNORECASE - Same as FIELD_CHECKREGEXP except
  573.                                       that case is ignored for
  574.                                       alphabetic characters.
  575.  
  576.        FIELD_FLUSHBUFFER - Keyboard is flushed before entering the
  577.                            field.  This will override whatever the
  578.                            FLUSH_KEYBOARD() macro is set to.
  579.  
  580.        FIELD_HOMECURSOR  - Input field will be scrolled back to the
  581.                            first character when the field is accepted.
  582.                            This is good for fields that have scrolled
  583.                            to the right.
  584.  
  585.  
  586.        FIELD_PROTECT - The input field will not be edited.  It will be
  587.                        skipped over by the form manager.
  588.  
  589.        FIELD_COMMA - This option is only used for numeric field types
  590.                      (CWL_INTEGER, CWL_UINTEGER, LONG, ULONG,
  591.                      CWL_DOUBLE and CWL_FLOAT types).  Commas are
  592.                      placed in the input when it is accepted.  While
  593.                      inputting in the field, the form manager deletes
  594.                      the commas.  To make sure that the comma formatted
  595.                      string will fit in the field, the field maximum
  596.                      width should be at least as long as the comma
  597.                      formatted number.
  598.  
  599.        FIELD_LJUSTIFY - The input field will be left justified when it
  600.                         is accepted.
  601.  
  602.        FIELD_RJUSTIFY - The input field will be right justified when it
  603.                         is accepted.
  604.  
  605.        FIELD_ZSUPPRESS1 - This option is used only for numeric field
  606.                           types.  The input will suppress all leading
  607.                           zeros when the field is accepted.
  608.  
  609.  
  610.  
  611.  
  612.          Page 7          The C Window Library                 Page 7
  613.  
  614.        FIELD_ZSUPPRESS2 - This option does the same as FIELD_ZSUPPRESS1
  615.                           except that if the string entered is all
  616.                           zeros, leading zeros except for the last zero
  617.                           is suppressed.  For example, if the user
  618.                           enters "00000" the resulting string after
  619.                           suppressing will be "0".
  620.  
  621.        FIELD_PASSWORD - This is a password field.  When inputting into
  622.                           this field, only the password character
  623.                         (default is the asterisk '*') is displayed.
  624.  
  625.        FIELD_CLEARFIELD - Clears the input field if the first key
  626.                         pressed is recognized by the regular expression
  627.                           as a valid input key.  If a cursor movement
  628.                           key is pressed first, the field is not
  629.                           cleared if any subsequent input keys are
  630.                           pressed.
  631.  
  632.        FIELD_CHECK - When this option is chosen the field is checked to
  633.                      make sure that the minimum number of characters
  634.                      have been entered when the user wants to exit the
  635.                      form.
  636.  
  637.        FIELD_OVERRIDE_FORWARD - You can go to the next field (go toward
  638.                                 the last field) from the input field
  639.                                 without checking to see if the minimum
  640.                                 number of characters has been entered.
  641.                                 However, you cannot go to a previous
  642.                                 field (go toward the first field) if
  643.                                 the minimum number of characters is not
  644.                                 met.
  645.  
  646.        FIELD_OVERRIDE_BACKWARD - Same as FIELD_OVERRIDE_FORWARD except
  647.                                  that you cannot go forward (toward the
  648.                                  last input field) without meeting the
  649.                                  requirements of entering the minimum
  650.                                  number of characters expected.
  651.  
  652.        NO_FIELD_OPTIONS        - The above options described are turned
  653.                                  off.
  654.  
  655.        You can combine options with a bitwise OR (|).  For example, if
  656.        you want a numeric field zero suppressed, comma formatted, and
  657.        left justified you would do the following:
  658.  
  659.                FIELD_ZSUPPRESS1 | FIELD_COMMA | FIELD_LJUSTIFY
  660.  
  661.        If both FIELD_ZSUPPRESS1 and FIELD_ZSUPPRESS2 are used as
  662.        options, FIELD_ZSUPPRESS1 overrides FIELD_ZSUPPRESS2.
  663.  
  664.        FIELD_LJUSTIFY overrides FIELD_RJUSTIFY if both options are
  665.        chosen.
  666.  
  667.        If both FIELD_OVERRIDE_FORWARD and FIELD_OVERRIDE_BACKWARD are
  668.        chosen, you can exit a field in any direction without checking
  669.        the regular expression.
  670.        NO_FIELD_OPTIONS must not be combined with any other options.
  671.  
  672.          Page 8          The C Window Library                 Page 8
  673.  
  674.        You can also turn off and turn on field options at run time and
  675.        during processing of a form by using the FormSetFieldOptions()
  676.        function defined later in the manual.
  677.  
  678.  
  679.  
  680.        Field Starting Input Position
  681.        -----------------------------
  682.  
  683.        This value tells the form manager where to place the cursor when
  684.        input is started.  The position numbers range from 0 to the
  685.        highest field position in the input field, less one.  Usually
  686.        the starting position for the field is 0, but you can start the
  687.        input anywhere in a field.
  688.  
  689.        Field Attributes
  690.        ----------------
  691.  
  692.        The tenth member of the FIELD_ENTRY structure is the field
  693.        attribute.  This attribute will be the color of the field
  694.        characters that are inputted.  Note that in the example above,
  695.        the constants BLACK_ and WHITE_ are used instead of the usual
  696.        lower case global variables, black and white.  This is done
  697.        because the lower case color variables do not have a value until
  698.        WindowInitializeSystem() is called, while the capitalized
  699.        constants have a value that is predefined.  We need to use the
  700.        predefined constants because we are initializing an array
  701.        outside of the main() function.
  702.  
  703.  
  704.  
  705.        Field Regular Expression
  706.        ------------------------
  707.  
  708.        The last member of the FIELD_ENTRY is the regular expression to
  709.        use.  It is wise to use the proper regular expression for a
  710.        given field type.  For example, use a [0-9] type regular
  711.        expression for integer data.  Here are a list of sample regular
  712.        expressions to use for a given data type:
  713.  
  714.  
  715.                Constant                         Simple Reg.
  716.                Data Type                        Expression
  717.                ---------                        ----------
  718.  
  719.                CWL_INTEGER or CWL_LINTEGER      [0-9], [0-9/-+]
  720.  
  721.                CWL_UINTEGER or CWL_ULINTEGER    [0-9]
  722.  
  723.                CWL_STRING                       Any regular expression.
  724.  
  725.                CWL_CHAR                         Any one character regular
  726.                                                 expression.
  727.  
  728.                CWL_DOUBLE or CWL_FLOAT        [0-9], [0-9/-+], [0-9/.],
  729.                                               [0-9/.eE]
  730.  
  731.  
  732.          Page 9          The C Window Library                 Page 9
  733.  
  734.        Except for the CWL_CHAR data type, you can use multiplying
  735.        factors or complex regular expressions composed of the above
  736.        regular expressions.  The regular expressions defined above are
  737.        just examples of what you should use.
  738.  
  739.        The total length of the number of characters in the regular
  740.        expression must not exceed the maximum number of characters in a
  741.        field.  The current maximum number of characters allowed in a
  742.        field is 255.  If you want to change this, you must modify the
  743.        source code and change the constant MAXFIELDSIZE to whatever
  744.        value you choose.  Of course, you would have to recompile the
  745.        source code.
  746.  
  747.  
  748.  
  749.        Alternate Methods of Creating FIELD_ENTRY's
  750.        ------------------------------------------
  751.  
  752.        Another method of creating the FIELD_ENTRY's is to create them
  753.        dynamically.  Here is an example:
  754.  
  755.        #include "cwlwin.h"
  756.        #define NUMFIELDS 5
  757.        #define NORM  CREATE_VIDEO_ATTRIBUTE(black,white)
  758.  
  759.        FIELD_ENTRY_PTR field_array;   /* Notice that we have a pointer
  760.                                          to what will be an array of
  761.                                          FIELD_ENTRY's */
  762.        main()
  763.        {
  764.          WindowInitializeSystem();
  765.          FormInitializeSystem();
  766.          FormInitializeFloat();
  767.  
  768.        /* Initialize with at least number of total fields */
  769.          field_array = FieldAllocate(NUMFIELDS);
  770.  
  771.        /* Call function to create fields in field_array sequentially*/
  772.          FieldCreate(field_array,   /* FIELD_ENTRY pointer */
  773.                          0,             /* field number */
  774.  
  775.        /* The rest of the arguments are just like the first example */
  776.                        CWL_INTEGER,         /* field type */
  777.                        0,               /* field row */
  778.                        19,              /* field column */
  779.                        "___",           /* field mask */
  780.                        '_',             /* fill character */
  781.                        1,               /* minimum characters */
  782.                        3,               /* maximum field width */
  783.                        FIELD_RJUSTIFY,  /* field options */
  784.                        0,               /* starting position */
  785.                        NORM,            /* attribute */
  786.                        "3[0-9]");       /* regular expression */
  787.  
  788.          FieldCreate(field_array,1,CWL_STRING,1,19,"__________",'_',
  789.                          0,10, NO_FIELD_OPTIONS,0,NORM,"10.");
  790.  
  791.  
  792.          Page 10          The C Window Library                 Page 10
  793.  
  794.          FieldCreate(field_array,2,CWL_INTEGER,2,19,"__",'_',2,2,
  795.                      NO_FIELD_OPTIONS,0,NORM,"2[0-9]");
  796.  
  797.  
  798.          FieldCreate(field_array,3,CWL_DOUBLE,3,19, "_______",'_',1,7,
  799.                      FIELD_COMMA | FIELD_LJUSTIFY,0,NORM,"7[0-9/.]");
  800.  
  801.  
  802.          FieldCreate(field_array,4,CWL_CHAR,4,19,"_",'_',1,1,
  803.                      FIELD_UPPERCASE,0,NORM,"[YyNn]");
  804.  
  805.          /* Terminate fields with FieldEnd */
  806.          FieldEnd(field_array,NUMFIELDS);
  807.          /*
  808.                 some other stuff
  809.                                          */
  810.  
  811.          /* Dispose of Field entries created */
  812.          FieldDeallocate(field_array);
  813.        }
  814.  
  815.  
  816.        The difference between the above method and the method used to
  817.        globally initialize an array are the following:
  818.  
  819.        1) The variable type for field_array is FIELD_ENTRY_PTR, not
  820.        FIELD_ENTRY as the previous examples so far have illustrated.
  821.  
  822.        2) You must call the FieldAllocate() function to allocate space
  823.        for the number of fields desired.  If you do not call field
  824.        allocate, you will surely get a memory overwrite error.  The
  825.        return value to FieldAllocate() must be assigned to a
  826.        FIELD_ENTRY_PTR, as the above example shows.
  827.  
  828.        The array of fields are allocated from the heap at runtime, as
  829.        opposed to the static method which sets up the memory scheme at
  830.        link time.
  831.  
  832.        3) The next thing you must do is to fill in the field
  833.        information by calling the FieldCreate() function.  The first
  834.        argument to the FieldCreate() function is the FIELD_ENTRY_PTR.
  835.        The second argument is the field number to assign this
  836.        information to.  The rest of the arguments are the same order as
  837.        the first example i.e.  field type, row, column, mask, etc.
  838.        FieldCreate() is called for each field desired.
  839.  
  840.        4) The FieldEnd() function must be called to terminate the list
  841.        of fields.  The first argument is the FIELD_ENTRY_PTR, and the
  842.        second argument is the total number of fields defined.
  843.  
  844.        5) After you have called FormClose() (discussed later) and no
  845.        longer need the array of fields anymore, you should call
  846.        FieldDeallocate() to free the memory assigned to the array of
  847.        fields.  The only argument to FieldDeallocate() is the
  848.        FIELD_ENTRY_PTR.
  849.  
  850.  
  851.  
  852.          Page 11          The C Window Library                 Page 11
  853.  
  854.        All of these functions except for FieldAllocate() have no return
  855.        values.  The FieldAllocate() function returns a FIELD_ENTRY_PTR
  856.        if successful, and a FIELD_ENTRY_NULL_PTR if unsuccessful.
  857.  
  858.        The advantages of using the above method over the first method
  859.        is that FIELD_ENTRY's are dynamically allocated rather than
  860.        statically declared at compile time.  This allows the programmer
  861.        to create loops to set up fields, read field information from a
  862.        file and assign this info to a FIELD_ENTRY, etc.
  863.  
  864.  
  865.        The disadvantages of this method is that you have to call
  866.        several functions to accomplish creating an array of fields,
  867.        while the static method does not call any functions.  Function
  868.        overhead is saved in the static method.
  869.  
  870.  
  871.        Here is another method of using statically defined data and
  872.        function calls:
  873.  
  874.        #include "cwlwin.h"
  875.        #define NUMFIELDS 5
  876.        #define NORM  CREATE_VIDEO_ATTRIBUTE(black,white)
  877.  
  878.        FIELD_ENTRY field_array[NUMFIELDS+1]; /* Notice that we have an
  879.                                               array of FIELD_ENTRY's. 1
  880.                                               is added for FIELDEND
  881.                                               entry */
  882.  
  883.        main()
  884.        {
  885.          WindowInitializeSystem();
  886.          FormInitializeSystem();
  887.        /* Call function to create fields in field_array sequentially */
  888.          FieldCreate(field_array,0,CWL_INTEGER,0,19,"___",'_',1,3,
  889.                      FIELD_RJUSTIFY,0,NORM,"3[0-9]");
  890.  
  891.          FieldCreate(field_array,1,CWL_STRING,1,19,"__________",'_',
  892.                      0,10,NO_FIELD_OPTIONS,0,NORM,"10.");
  893.  
  894.          FieldCreate(field_array,2,CWL_INTEGER,2,19,"__",'_',2,2,
  895.                      NO_FIELD_OPTIONS,0,NORM,"2[0-9]");
  896.  
  897.          FieldCreate(field_array,3,CWL_DOUBLE,3,19, "_______",'_',1,7,
  898.                      FIELD_COMMA | FIELD_LJUSTIFY,0,NORM,"7[0-9/.]");
  899.  
  900.          FieldCreate(field_array,4,CWL_CHAR,4,19,"_",'_',1,1,
  901.                      FIELD_UPPERCASE,0,NORM,"[YyNn]");
  902.  
  903.        /* Terminate fields with FieldEnd */
  904.          FieldEnd(field_array,NUMFIELDS);
  905.  
  906.        }
  907.  
  908.  
  909.  
  910.  
  911.  
  912.          Page 12          The C Window Library                 Page 12
  913.  
  914.        The above method declares an array of FIELD_ENTRY's, but does
  915.        not initialize them in the same way as the first method.  Note
  916.        that there is no function call to FieldAllocate() or
  917.        FieldDeallocate() since the array of fields, field_array, was
  918.        already declared with 6 elements (NUMFIELDS + 1).  All other
  919.        aspects of this method is the same as the second method.
  920.  
  921.        This method statically declares an array but does have to
  922.        allocate any memory from the heap.
  923.  
  924.        From this point on, this manual will use the first method
  925.        discussed on page 2 when code fragments are written.
  926.  
  927.  
  928.  
  929.        FormInitialize() function
  930.        -------------------------
  931.  
  932.        The next step is to take the array of FIELD_ENTRY's and assign
  933.        them to a window.  The FormInitialize() does just this.
  934.  
  935.        A prototype of this function is as follows:
  936.  
  937.        FORMPTR FormInitialize(void *window, FIELD_ENTRY *field_entry,
  938.                               int form_options)
  939.  
  940.        Note that this function returns a pointer to a structure.  This
  941.        pointer is called a FORMPTR.  You must assign the return value
  942.        to a variable declared as a FORMPTR.
  943.  
  944.        The first argument to FormInitialize() seems strange.  The
  945.        reason for the void pointer instead of the usual WPOINTER or
  946.        VWPOINTER is that either WPOINTER or VWPOINTER can be used as
  947.        the first argument.  As was stated before, forms can either be
  948.        window based or virtual window based.
  949.  
  950.        If the first argument is a WPOINTER, the window must be
  951.        initialized and opened before calling FormInitialize().  If the
  952.        first argument is a VWPOINTER, the virtual window must be
  953.        initialized with VirtualInitialize() and must be an attributed
  954.        virtual window (VirtualInitialize() must be called with
  955.        ATTRIBUTE as the first argument).
  956.  
  957.        The second argument is the array of FIELD_ENTRY's.
  958.  
  959.        The third argument are the form options.  A list of the form
  960.        options are as follows:
  961.  
  962.  
  963.        Form Option
  964.        -----------
  965.  
  966.        FORM_WRAP    -  form manager will move the input cursor to the
  967.                        first input field if the last input field is
  968.                        accepted, and will move the input cursor to the
  969.                        last input field if the cursor goes beyond the
  970.                        first field.
  971.  
  972.          Page 13          The C Window Library                 Page 13
  973.  
  974.  
  975.        FORM_CHECK   -  When this option is on, all fields are checked
  976.                        on exit of the form to see if they satisfy the
  977.                        minimum number of characters.
  978.  
  979.        FORM_EXIT_INITIAL - This option allows exiting a form if an
  980.                            attempt is made to move the input cursor
  981.                            above the first input field in the form.
  982.  
  983.        FORM_NOEXIT_LAST - When this option is on, the form is not
  984.                           exited when the last field is accepted.
  985.  
  986.  
  987.        FORM_HIGHLIGHT - When this option is on, each field takes on its
  988.                        field color only when it is being inputted.
  989.                        When a field is not being inputted, the color of
  990.                        the field is the text color of the window.
  991.  
  992.                        When this option is off, all fields take on
  993.                        their color regardless if the field is currently
  994.                        being inputted.
  995.  
  996.        FORM_VIRTUAL -  You must use this option if the first argument
  997.                        to FormInitialize() is a VWPOINTER.
  998.  
  999.        FORM_STATIC -   The form window will not be hidden when the form
  1000.                        is exited.
  1001.  
  1002.        NO_FORM_OPTIONS  -  All options described above are turned off.
  1003.  
  1004.        You can combine form options using the bitwise OR (|).  Form
  1005.        options can be turned off or on any time using the
  1006.        FormSetOptions() function defined later in the manual.
  1007.  
  1008.        Example:
  1009.  
  1010.        #include "cwlwin.h"
  1011.        #define NORM  CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  1012.  
  1013.        WPOINTER w;
  1014.        VWPOINTER vw;
  1015.  
  1016.        FORMPTR form,   /* pointers to FORM's */
  1017.                form2;
  1018.  
  1019.        FIELD_ENTRY field_array[] =
  1020.  
  1021.         {CWL_INTEGER,0,19,"___",'_',1,3,FIELD_RJUSTIFY,0,NORM,"3[0-9]",
  1022.          CWL_STRING, 1, 19, "__________", '_', 0, 10,NO_FIELD_OPTIONS,
  1023.                  0,NORM, "10.",
  1024.          CWL_INTEGER,2, 19, "__", '_', 2, 2,NO_FIELD_OPTIONS, 0,NORM,
  1025.                  "2[0-9]",
  1026.          CWL_DOUBLE,3, 19,"_______",'_',1,7,FIELD_COMMA|FIELD_LJUSTIFY,
  1027.                  0,NORM,"7[0-9/.]",
  1028.          CWL_CHAR, 4, 19, "_", '_', 1, 1, FIELD_UPPERCASE, 0,NORM,
  1029.                  "[YyNn]",
  1030.          FIELDEND };
  1031.  
  1032.          Page 14          The C Window Library                 Page 14
  1033.  
  1034.        main()
  1035.        {
  1036.          WindowInitializeSystem();
  1037.          WindowInitDesktop(0);
  1038.          FormInitializeSystem();
  1039.          FormInitializeFloat();
  1040.          w = WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,40,10,
  1041.                               NORM,NORM,SINGLEBOX);
  1042.          /* vw must be ATTRIBUTEd if we want to use it as a form */
  1043.          vw = VirtualInitialize(ATTRIBUTE,10,80,NORM);
  1044.  
  1045.          /* Initialize with WPOINTER */
  1046.          form = FormInitialize(w,  /* window to assign form to */
  1047.                                field_array, /* array of fields */
  1048.                                NO_FORM_OPTIONS); /* form options */
  1049.  
  1050.          if (form == FORM_NULL_PTR)
  1051.          {
  1052.            printf("Form could not be initialized");
  1053.            exit(0);
  1054.          }
  1055.  
  1056.          /* Initialize with VWPOINTER */
  1057.          form2 = FormInitialize(vw, field_array, FORM_VIRTUAL);
  1058.          {
  1059.            printf("Form could not be initialized");
  1060.            exit(0);
  1061.          }
  1062.        }
  1063.  
  1064.        Note that when initializing with a virtual window, the option
  1065.        FORM_VIRTUAL must be used as a form option.
  1066.  
  1067.        FormInitialize() returns a valid FORMPTR if successful.  If
  1068.        there is an error, a FORM_NULL_PTR (null FORMPTR) is returned,
  1069.        and window_error_code is set to one of the following:
  1070.  
  1071.        NO_FIELDS_DEFINED if there are no fields in the FIELD_ENTRY
  1072.        array.
  1073.  
  1074.        NO_HEAP_MEM if there is not enough memory to allocate for the
  1075.        form and any internal field buffers.
  1076.  
  1077.        NO_INPUT_CHARS if a field mask contains no characters.
  1078.  
  1079.        INVALID_NUM_CHARS if the number of characters denoted by a
  1080.        field's regular expression does not equal the number of input
  1081.        positions in the field mask.
  1082.  
  1083.        BAD_WINDOW if the window does not exist.
  1084.  
  1085.        WINDOW_NOT_OPEN if the window is not open for writing.
  1086.  
  1087.        BAD_V_WINDOW if the virtual window specified does not exist.
  1088.  
  1089.        FIELD_RANGE_ERROR if there is a field that is out of bounds of
  1090.        the dimensions of the window or the virtual window.
  1091.  
  1092.          Page 15          The C Window Library                 Page 15
  1093.  
  1094.        Field Errors
  1095.        ------------
  1096.  
  1097.        If there is an error with a particular field, the global
  1098.        variable field_bad_number tells which field is the offending
  1099.        field.  Field numbers are numbered from 1 to the highest field
  1100.        in the array of fields.
  1101.  
  1102.        Here is how a complete form error checking function routine
  1103.        would look like:
  1104.  
  1105.        #include "cwlwin.h"
  1106.        #include <stdio.h>
  1107.  
  1108.        FIELD_ENTRY field_array[] = {   /* ... Initialize fields ... */ }
  1109.        VWPOINTER vw;
  1110.        WPOINTER w;
  1111.        FORMPTR form;
  1112.  
  1113.        main()
  1114.        {
  1115.          WindowInitializeSystem();
  1116.          FormInitializeSystem();
  1117.          FormInitializeFloat();
  1118.          WindowInitDesktop(0);
  1119.          w = WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,40,10,
  1120.                               NORM,NORM,SINGLEBOX);
  1121.          /* vw must be ATTRIBUTEd if we want to use it as a form */
  1122.          vw = VirtualInitialize(ATTRIBUTE,10,80,NORM);
  1123.  
  1124.          /* Initialize with WPOINTER */
  1125.          form = FormInitialize(w,  /* window to assign form to */
  1126.                                field_array, /* array of fields */
  1127.                                NO_FORM_OPTIONS); /* form options */
  1128.  
  1129.          if (form == FORM_NULL_PTR)
  1130.            write_form_error(1);
  1131.  
  1132.          /* Initialize with VWPOINTER */
  1133.          form2 = FormInitialize(vw, field_array, FORM_VIRTUAL);
  1134.          if (form2 == FORM_NULL_PTR)
  1135.            write_form_error(2);
  1136.        }
  1137.  
  1138.        void write_form_error(int formnum)
  1139.        {
  1140.          switch (window_error_code)
  1141.          {
  1142.            case NO_FIELDS_DEFINED:
  1143.              printf("Form %d has no fields",formnum);
  1144.            break;
  1145.  
  1146.            case NO_HEAP_MEM:
  1147.              printf("Not enough heap memory to allocate for form %d",
  1148.                      formnum);
  1149.            break;
  1150.  
  1151.  
  1152.          Page 16          The C Window Library                 Page 16
  1153.  
  1154.            case NO_INPUT_CHARS:
  1155.               printf ("Field %d has an invalid mask in form %d",
  1156.                        field_bad_number, formnum);
  1157.            break;
  1158.  
  1159.            case TOO_MANY_CHARS:
  1160.             printf("Field %d has too many input characters in form %d",
  1161.                       field_bad_number, formnum);
  1162.            break;
  1163.  
  1164.            case BAD_WINDOW:
  1165.             printf("Window or virtual window does not exist for"
  1166.                    " form %d", formnum);
  1167.            break;
  1168.  
  1169.            case WINDOW_NOT_OPEN:
  1170.               printf("Window not open for form %d",formnum);
  1171.            break;
  1172.  
  1173.            case BAD_V_WINDOW:
  1174.               printf("Virtual window does not exist for form %d",
  1175.                       formnum);
  1176.            break;
  1177.  
  1178.            case FIELD_RANGE_ERROR:
  1179.               printf("Field %d is out of bounds in form %d",
  1180.                       field_bad_number,formnum);
  1181.            break;
  1182.  
  1183.            default:
  1184.               printf("Undefined error for form %d",formnum);
  1185.            break;
  1186.          }
  1187.          exit(0);
  1188.        }
  1189.  
  1190.        The above function write_error_form() processes any error that
  1191.        may occur when initializing a form.
  1192.  
  1193.  
  1194.  
  1195.  
  1196.  
  1197.        Setting Number of Decimal Places in a field with
  1198.        FormSetFieldDecimal()
  1199.        ---------------------
  1200.  
  1201.        If the field type is CWL_FLOAT or CWL_DOUBLE, the form manager
  1202.        should be informed of the number of decimal places in the field.
  1203.        The FormSetFieldDecimal() function tells the form manager the
  1204.        number of decimal places in a field.  Here is the prototype:
  1205.  
  1206.        int FormSetFieldDecimal(FORMPTR form, int entry, int numdec)
  1207.  
  1208.  
  1209.  
  1210.  
  1211.  
  1212.          Page 17          The C Window Library                 Page 17
  1213.  
  1214.        The first two arguments are the form and entry number,
  1215.        respectively, and the last argument is the number of decimal
  1216.        places.  If the FormSetFieldDecimal() function is not called,
  1217.        the form manager will assume 0 decimal places.  The form manager
  1218.        will round off any number that is inputted to the desired
  1219.        decimal places.
  1220.  
  1221.  
  1222.        If there are no errors, FormSetFieldDecimal() returns NO_ERROR.
  1223.  
  1224.        If there are errors, FormSetFieldDecimal() returns one of the
  1225.        following and sets window_error_code to one these values:
  1226.  
  1227.        UNDEFINED_FORM if the FORMPTR does not exist.
  1228.  
  1229.        UNDEFINED_FIELD if the field entry does not exist.
  1230.  
  1231.  
  1232.  
  1233.  
  1234.  
  1235.  
  1236.  
  1237.  
  1238.  
  1239.  
  1240.  
  1241.  
  1242.  
  1243.  
  1244.  
  1245.  
  1246.  
  1247.  
  1248.  
  1249.  
  1250.  
  1251.  
  1252.  
  1253.  
  1254.  
  1255.  
  1256.  
  1257.  
  1258.  
  1259.  
  1260.  
  1261.  
  1262.  
  1263.  
  1264.  
  1265.  
  1266.  
  1267.  
  1268.  
  1269.  
  1270.  
  1271.  
  1272.          Page 18          The C Window Library                 Page 18
  1273.  
  1274.                               SPECIAL DATA TYPES
  1275.                               ------------------
  1276.  
  1277.        In the previous section, there was a very brief discussion of
  1278.        the special data types, namely CWL_LIST, CWL_TOGGLE,
  1279.        CWL_SUBFORM, CWL_VSUBFORM, CWL_BUTTON, CWL_RADIO, and
  1280.        CWL_CHECKBOX.  These special data types are very useful if the
  1281.        information to be entered for a field is not a normal text
  1282.        field.  For example, CWL_LIST allows you to use a popup list of
  1283.        choices to be displayed, CWL_TOGGLE allows you to toggle between
  1284.        choices, and CWL_SUBFORM and CWL_VSUBFORM allows you to enter a
  1285.        subform for a field.  The CWL_BUTTON field is a no input field,
  1286.        but powerful in what it can do.  CWL_BUTTON fields can close
  1287.        forms, go to previous fields, or can have a user defined
  1288.        definition if the user 'accepts' the field.  The CWL_RADIO field
  1289.        implements a radio button field, and CWL_CHECKBOX implements a
  1290.        check box type field.  A discussion of radio and check box
  1291.        fields will be discussed below.
  1292.  
  1293.        For all of the special fields, the field type specified when the
  1294.        fields on the form was initialized must match with the desired
  1295.        special field for the field entry.
  1296.  
  1297.  
  1298.        The CWL_LIST special field
  1299.        --------------------------
  1300.  
  1301.        If a field type is CWL_LIST, the form manager will display a
  1302.        pop-up menu of choices.  Once the selection is made, the string
  1303.        in the pop-up menu is written to the field.  The field should be
  1304.        big enough to hold the longest string in the pop-up menu.  Where
  1305.        does the form get the pop-up menu from?  You create the pop-up
  1306.        menu just like any normal popup menu.  If you are not familiar
  1307.        with creating pop-up menus, please refer to the documentation
  1308.        included with The C Window Library main documentation.
  1309.  
  1310.        To let the form know about the pop-up menu, you must call the
  1311.        FormSetListField() function.  This function lets the form know
  1312.        the address of the pop-up menu pointer (POPUP_MENU_PTR).  Here
  1313.        is the prototype:
  1314.  
  1315.        int FormSetListField(FORMPTR form, int entry, int rank,
  1316.                             int start, POPUP_MENU_PTR pop)
  1317.  
  1318.        The first argument is the pointer to the form.  The second
  1319.        argument is the form entry to assign the POPUP_MENU_PTR to.  THe
  1320.        third argument is the rank of the popup window.  The fourth
  1321.        argument is the starting entry to place the highlight on.  Entry
  1322.        numbers are numbered from 1 to the highest entry.  The last
  1323.        argument is the POPUP_MENU_PTR itself.
  1324.  
  1325.        The form must be initialized with FormInitialize(), the entry
  1326.        number must exist and must have been defined as a CWL_LIST
  1327.        field, and the POPUP_MENU_PTR must also have been created before
  1328.        calling FormSetListField().  If any of these criteria are
  1329.        violated, an error is returned.  Here is an example:
  1330.  
  1331.  
  1332.          Page 19          The C Window Library                 Page 19
  1333.  
  1334.        #include "cwlwin.h"
  1335.  
  1336.        FIELD_ENTRY fentry[] = {CWL_LIST,8,14,"________",' ',0,8,
  1337.                                NO_FIELD_OPTIONS,0,REVERSE,"8.",
  1338.                                FIELDEND};
  1339.        FORMPTR form;
  1340.        POPUP_MENU_ENTRY popup_entry[] = {"Choice 1",0,0,0,NULLFN,
  1341.                                        "Choice 2",1,0,0,NULLFN,
  1342.                                        "Choice 3",2,0,0,NULLFN,
  1343.                                        "Choice 4",3,0,0,NULLFN,
  1344.                                         CWL_NULL,-1};
  1345.  
  1346.        POPUP_MENU_PTR popup;
  1347.        unsigned menu_colors[NUMPOPUPCOLORS];
  1348.        WPOINTER w;
  1349.        main()
  1350.        {
  1351.          int i;
  1352.          WindowInitializeSystem();
  1353.          FormInitializeSystem();
  1354.          WindowInitDesktop(0);
  1355.  
  1356.          /* set up menu colors */
  1357.          menu_colors[ENTRYCOLOR] = CREATE_VIDEO_ATTRIBUTE(white,black);
  1358.          menu_colors[BORDERCOLOR] =CREATE_VIDEO_ATTRIBUTE(white,black);
  1359.          menu_colors[HOTKEYCOLOR] =CREATE_VIDEO_ATTRIBUTE(white,blue);
  1360.          menu_colors[HIGHLIGHTCOLOR]=CREATE_VIDEO_ATTRIBUTE(cyan,black);
  1361.          menu_colors[UNAVAILCOLOR]=CREATE_VIDEO_ATTRIBUTE(white,black);
  1362.          w = WindowInitialize(DESKTOP_WINDOW,BORDER,1,1,78,22,NORM,
  1363.                               NORM,SINGLEBOX);
  1364.  
  1365.          /* create popup menu */
  1366.          popup = PopupCreateMenu(popup_entry,menu_colors,3,9,7,
  1367.                                  NO_POPUP_OPTIONS,WNULLFN,VWNULLFN);
  1368.  
  1369.          /* Initialize form */
  1370.          form = FormInitialize(w,fentry,FORM_HIGHLIGHT);
  1371.          /* Let form know about popup menu */
  1372.          FormSetListField(form,0,1,0,popup);
  1373.  
  1374.          /* get the input */
  1375.          FormGetInput(form,1,0);
  1376.        }
  1377.  
  1378.        If you take a look at the array of FIELD_ENTRY's, the first
  1379.        field type is a CWL_LIST field.  This informs the form manager
  1380.        that the first field will have a pop-up list associated with it.
  1381.  
  1382.        Also note that The POPUP_MENU_ENTRY's menu function is a NULLFN.
  1383.        The C Window Library automatically assigns an internal function
  1384.        to the pop-up menu when FormSetListField() is called, which will
  1385.        supersede any function that you may have assigned to the menu
  1386.        entry.
  1387.  
  1388.        When FormSetListField() is called, the FORMPTR is assigned the
  1389.        POPUP_MENU_PTR, and any menu function is overridden by the C
  1390.        Data Forms function.
  1391.  
  1392.          Page 20          The C Window Library                 Page 20
  1393.  
  1394.        With a pop-up list, you can have hotkeys, secondary hotkeys,
  1395.        pre-functions, mouse support, etc. just like pop-up menus.  The
  1396.        only limit is that the function to perform when a selection is
  1397.        made is a Data Forms internal function, and not the function
  1398.        that you may have assigned to it previously.
  1399.  
  1400.        If there are no errors, FormSetListField() returns NO_ERROR.
  1401.  
  1402.        If there are errors, FormSetListField() returns one of the
  1403.        following and sets window_error_code to one these values:
  1404.  
  1405.        UNDEFINED_FORM if the FORMPTR does not exist.
  1406.  
  1407.        UNDEFINED_FIELD if the field entry does not exist.
  1408.  
  1409.        NO_HEAP_MEM if there is not enough memory to create the data
  1410.        structure required for a CWL_LIST field.
  1411.  
  1412.  
  1413.        Retrieving the CWL_LIST selection
  1414.        ---------------------------------
  1415.  
  1416.        To inspect the choice that was selected, use the
  1417.        FormGetListChoice() function.  Here is the prototype:
  1418.  
  1419.        int FormGetListChoice(FORMPTR form, int entry)
  1420.  
  1421.        The only two arguments are the form and entry number of the
  1422.        CWL_LIST field.  If successful, FormGetListChoice() returns an
  1423.        integer denoting the CWL_LIST entry that was selected.  Entry
  1424.        numbers are numbered from 0 to the highest entry in the list
  1425.        less one, and are numbered in the order that was specified in
  1426.        the pop-up menu.
  1427.  
  1428.        If the CWL_LIST field is protected, FormGetListChoice() returns
  1429.        0.
  1430.  
  1431.        If there are errors, FormGetListChoice() returns one of the
  1432.        following:
  1433.  
  1434.        UNDEFINED_FORM if the form does not exist.
  1435.  
  1436.        UNDEFINED_FIELD if the field does not exist, or the field is not
  1437.        a CWL_LIST field.
  1438.  
  1439.  
  1440.        The CWL_TOGGLE special field
  1441.        ----------------------------
  1442.  
  1443.        The CWL_TOGGLE field allows you to make selections by pressing
  1444.        the space bar (default) to cycle through selections.  You can
  1445.        also accomplish the same thing with a CWL_LIST field, with a
  1446.        one-line borderless pop-up window.  However, CWL_TOGGLE fields
  1447.        are much easier to use.  To let the FORMPTR know that a field is
  1448.        a toggle field, the FIELD_ENTRY field type must have a
  1449.        CWL_TOGGLE type, and you must call the FormSetToggleField()
  1450.        function to assign the pointer to the CWL_TOGGLE list.
  1451.  
  1452.          Page 21          The C Window Library                 Page 21
  1453.  
  1454.        Here is a small example that creates a CWL_TOGGLE list:
  1455.  
  1456.        char *toglist[] = {"ITEM1", "ITEM2", "ITEM3", TOGGLE_NULL};
  1457.  
  1458.        In other words, the CWL_TOGGLE list is just an array of
  1459.        character strings, with the last character string being the
  1460.        TOGGLE_NULL constant.  You MUST have the TOGGLE_NULL constant to
  1461.        terminate the array of string, or else the form manager will not
  1462.        know where the CWL_TOGGLE list ends.  Of course this is only one
  1463.        of many ways to create and initialize an array of character
  1464.        strings.
  1465.  
  1466.        The prototype to the FormSetToggleField() is as follows:
  1467.  
  1468.        int FormSetToggleField(FORMPTR form, int entry, char **toglist)
  1469.  
  1470.        The first argument is the pointer to the form.  The second
  1471.        argument is the form entry to assign the toggle array to, and
  1472.        the third argument is the toggle character array.  The form must
  1473.        be initialized with FormInitialize(), the entry number must
  1474.        exist and must have been defined as a CWL_TOGGLE field.
  1475.  
  1476.        Here is an example:
  1477.  
  1478.        #include "cwlwin.h"
  1479.        #define NORM  CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  1480.        #define REVERSE CREATE_VIDEO_ATTRIBUTE(WHITE_,BLACK_)
  1481.  
  1482.        FIELD_ENTRY fentry[] = {CWL_TOGGLE,0,0,"________",' ',0,8,
  1483.                         NO_FIELD_OPTIONS,0,REVERSE,"8.",FIELDEND};
  1484.        FORMPTR form;
  1485.        char *tog[] = {"Choice 1","Choice 2","Choice 3","Choice 4",
  1486.                       TOGGLE_NULL};
  1487.  
  1488.        WPOINTER w;
  1489.        main()
  1490.        {
  1491.          int i;
  1492.          WindowInitializeSystem();
  1493.          FormInitializeSystem();
  1494.          WindowInitDesktop(0);
  1495.          w = WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,78,22,NORM,
  1496.                               NORM,SINGLEBOX);
  1497.          /* Initialize form */
  1498.          form = FormInitialize(w,fentry,FORM_HIGHLIGHT|FORM_STATIC);
  1499.  
  1500.          /* Let form know about toggle field */
  1501.          FormSetToggleField(form,0,tog);
  1502.  
  1503.          /* get the input */
  1504.          FormGetInput(form,1,0);
  1505.          WindowMoveCursor(w,2,0);
  1506.  
  1507.          /* get the choice */
  1508.          WindowPrintf(w,"The choice that was made was %d",
  1509.                          FormGetToggleChoice(form,1));
  1510.        }
  1511.  
  1512.  
  1513.          Page 22          The C Window Library                 Page 22
  1514.  
  1515.        By default, the toggle key is the space bar, but this can be
  1516.        changed by changing the field key definitions.  This will be
  1517.        discussed later in subsequent sections.
  1518.  
  1519.        If there are no errors, FormSetToggleField() returns NO_ERROR.
  1520.  
  1521.        If there are errors, FormSetToggleField() returns one of the
  1522.        following and sets window_error_code to one these values:
  1523.  
  1524.        UNDEFINED_FORM if the FORMPTR does not exist.
  1525.  
  1526.        UNDEFINED_FIELD if the field entry does not exist.
  1527.  
  1528.  
  1529.        Retrieving the toggle selection
  1530.        -------------------------------
  1531.  
  1532.        To get the selection that was made in a toggle field, use the
  1533.        FormGetToggleChoice() function.  This function returns the
  1534.        toggle entry that was selected.  Entries are numbered from 0 to
  1535.        the highest entry in the toggle field, less one.  Here is the 
  1536.        prototype:
  1537.  
  1538.        int FormGetToggleChoice(FORMPTR form, int entry)
  1539.  
  1540.        The arguments are the form and entry number of the toggle field.
  1541.        FormGetToggleChoice() returns -1 if the toggle field is a
  1542.        protected field.
  1543.  
  1544.        If there are errors, FormGetToggleChoice() returns one of the
  1545.        following:
  1546.  
  1547.        UNDEFINED_FORM if the form does not exist.
  1548.  
  1549.        UNDEFINED_FIELD if the field does not exist, or the field is not a
  1550.        CWL_TOGGLE field.
  1551.  
  1552.  
  1553.        CWL_SUBFORM and CWL_VSUBFORM special fields
  1554.        -------------------------------------------
  1555.  
  1556.        You can define a field in a form as another form.  When the
  1557.        field that is defined as a subform is entered, the form manager
  1558.        processes the subform.  When the subform is completed, the form
  1559.        manager returns control to the next field entry in the form that
  1560.        called the subform.  Subforms can contain other subforms, so
  1561.        there is no theoretical limit to the nesting level for subforms.
  1562.        If you have deeply nested subforms, make sure that you have
  1563.        enough stack space when compiling and linking your programs.
  1564.  
  1565.        The only difference between CWL_SUBFORM and CWL_VSUBFORM is that
  1566.        CWL_VSUBFORM informs the form manager that the subform is a
  1567.        virtual (scrolling) form.
  1568.  
  1569.  
  1570.  
  1571.  
  1572.  
  1573.          Page 23          The C Window Library                 Page 23
  1574.  
  1575.        The way to define a field as a CWL_SUBFORM or CWL_VSUBFORM is to
  1576.        make sure the field type for the FIELD_ENTRY is CWL_SUBFORM
  1577.        (CWL_VSUBFORM).  Setting up a subform is EXACTLY the same way as
  1578.        you would set up a regular form.  THERE IS NO DIFFERENCE!  Once
  1579.        your subform is set up, you must call the FormSetSubformField()
  1580.        for CWL_SUBFORMS, or FormSetVSubformField() for CWL_VSUBFORMS.
  1581.        Here are the prototypes:
  1582.  
  1583.        FormSetSubformField(FORMPTR form, int entry, int rank,
  1584.                            int start, FORMPTR subform)
  1585.  
  1586.        FormSetVSubformField(FORMPTR form, int entry, int rank,
  1587.                             int start, FORMPTR vsubform, WPOINTER viewport)
  1588.  
  1589.        The only difference between the two functions is that
  1590.        FormSetVSubformField() allows you to specify the viewport that
  1591.        the virtual form will be displayed on.  You must supply this
  1592.        argument if you want the virtual subform to work correctly.
  1593.  
  1594.        The first argument is the form to assign the subform to.  The
  1595.        second argument is the entry in the form that will be a subform
  1596.        field.  The third argument is the rank of the subform window.
  1597.        The fourth argument is the starting entry in the subform to
  1598.        begin getting input.  The fifth argument is the pointer to the
  1599.        subform itself.  The last argument in FormSetVSubformField() is
  1600.        the viewport window.  All of the above must exist, or an error
  1601.        will be returned.  Here is an example:
  1602.  
  1603.        #include "cwlwin.h"
  1604.        #define NORM  CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  1605.        #define REVERSE  CREATE_VIDEO_ATTRIBUTE(WHITE_,BLACK_)
  1606.  
  1607.        /* initialize entries for form 1 */
  1608.        FIELD_ENTRY fentry[] = {CWL_INTEGER,0,0,"________",' ',0,8,
  1609.                                NO_FIELD_OPTIONS,0,REVERSE,"8.",
  1610.                          CWL_SUBFORM,0,0,"",' ',0,0,NO_FIELD_OPTIONS,
  1611.                          0,0,"",FIELDEND};
  1612.  
  1613.        /* initialize entries for subform */
  1614.        FIELD_ENTRY fentry2[] =
  1615.          {CWL_INTEGER,0,0,"____",' ',0,4,NO_FIELD_OPTIONS,0,
  1616.                 REVERSE,"4.", FIELDEND};
  1617.  
  1618.        FORMPTR form,subform;
  1619.        WPOINTER w,w2;
  1620.        main()
  1621.        {
  1622.          int i;
  1623.          WindowInitializeSystem();
  1624.          FormInitializeSystem();
  1625.          WindowInitDesktop(0);
  1626.  
  1627.          w = WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,78,22,NORM,
  1628.                               NORM,SINGLEBOX);
  1629.          w2 = WindowInitialize(DESKTOP_WINDOW,BORDER,5,9,50,12,
  1630.                                NORM,NORM,SINGLEBOX);
  1631.  
  1632.  
  1633.          Page 24          The C Window Library                 Page 24
  1634.  
  1635.          /* Initialize form */
  1636.          form = FormInitialize(w,fentry,FORM_HIGHLIGHT);
  1637.          subform = FormInitialize(w2,fentry2,FORM_HIGHLIGHT);
  1638.  
  1639.          /* Let form know about subform field */
  1640.          FormSetSubformField(form,1,1,0,subform);
  1641.  
  1642.          /* get the input */
  1643.          FormGetInput(form,1,0);
  1644.        }
  1645.  
  1646.        Note that a CWL_SUBFORM (CWL_VSUBFORM) FIELD_ENTRY's only
  1647.        important parts are the field type, and options.  The mask,
  1648.        attribute, regular expression, start position, row, col, etc.
  1649.        are irrelevant since the field is a whole form.  This is why the
  1650.        CWL_SUBFORM field entry has bogus (don't care) arguments for
  1651.        these items.
  1652.  
  1653.        If there are no errors, FormSetSubformField() and
  1654.        FormSetVSubformField() return NO_ERROR.
  1655.  
  1656.        If there are errors the return value is one of the following
  1657.  
  1658.        UNDEFINED_FORM if the FORMPTR or subform FORMPTR does not exist.
  1659.  
  1660.        UNDEFINED_FIELD if the field entry does not exist.
  1661.  
  1662.  
  1663.  
  1664.        CWL_BUTTON fields
  1665.        -----------------
  1666.  
  1667.        A button field is a field that does not accept input but does
  1668.        certain actions when selected.  These actions can be anything
  1669.        from closing a form to doing a user-defined function.  When the
  1670.        button field is accepted, the action tied to the button field is
  1671.        done.  If the user wants to skip over the button field, he/she
  1672.        would hit a previous field or next field key.  These key
  1673.        definitions are discussed in the GETTING INPUT FROM A FORM
  1674.        section.
  1675.  
  1676.        To inform the form manager that a field is a button field, you
  1677.        must first set the field type to CWL_BUTTON.  Field types are
  1678.        set when defining the array of field entries.  After the field
  1679.        entries have been defined, the next step is to use the
  1680.        FormSetButtonField() function.  Here is the prototype to this
  1681.        function:
  1682.  
  1683.  
  1684.         int FormSetButtonField(FORMPTR form, int entry, int retval,
  1685.                               char *text, int *attr,
  1686.                               int (*button_func)(FORMPTR f, int e,
  1687.                                                   int *new_entry))
  1688.  
  1689.        The first argument is the form to set the button field.
  1690.  
  1691.        The second argument is the entry in the form to set as the
  1692.        button field.
  1693.  
  1694.  
  1695.  
  1696.          Page 25          The C Window Library                 Page 25
  1697.  
  1698.        The third argument is the value that will be returned to the
  1699.        form manager if the button field is accepted.  The possible
  1700.        return values and their descriptions will be discussed later.
  1701.  
  1702.        The fourth argument is a string that is written to the form
  1703.        window.  This string will be placed in the (row,col) coordinates
  1704.        specified when the field was defined.  This string should
  1705.        contain useful information to the user as to what the button
  1706.        will do if it is accepted.  For example, the string "Close" can
  1707.        be written to the form window if accepting the button will close
  1708.        the form.  This string is also highlighted when the button field
  1709.        is the current field.  If the FORM_HIGHLIGHT option is on, the
  1710.        button field is only highlighted when it is the current field.
  1711.  
  1712.        The fifth argument is an array of attributes that will be used
  1713.        for highlighting the button field if it is the active field, and
  1714.        lowlighting if it is not the active field.  The positions in
  1715.        this array denote the following colors:
  1716.  
  1717.        NORMATTR - This is the color of the unhighlighted button field.
  1718.        HIATTR   - This is the color of the highlighted button.
  1719.        For instance:
  1720.  
  1721.        int myattr[2];
  1722.        /* ... */
  1723.        myattr[NORMATTR] = CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_);
  1724.        myattr[HIATTR] = CREATE_VIDEO_ATTRIBUTE(WHITE_,BLACK_);
  1725.  
  1726.        The last argument is a pointer to a user-defined function that
  1727.        will return a value to the form manager.  The possible return
  1728.        values will be discussed later.  The user-defined function takes
  1729.        three arguments.  The first argument is a pointer to the form
  1730.        that called your user-defined function, and the second argument
  1731.        is the entry in the form that called your user-defined function.
  1732.        The third argument is a pointer to an integer that will denote a
  1733.        field number to change to if the FIELD_NEWFIELD value is
  1734.        returned to the form manager.  The FIELD_NEWFIELD value will be
  1735.        discussed below.
  1736.  
  1737.        An advantage of using a user-defined function is that the return
  1738.        value to the form manager can be dynamic.  In other words, your
  1739.        user-defined function controls what value is returned to the
  1740.        form manager.  You may have different return values that you
  1741.        want to implement depending on the state of the form, what input
  1742.        has been entered in previous fields, etc.  This user-defined
  1743.        function is not limited.  You can do just about anything in this
  1744.        function, including opening other forms, displaying windows,
  1745.        etc.
  1746.  
  1747.        The user-defined function MUST return a value to the form
  1748.        manager.  If not, unpredictable things may happen in the
  1749.        processing of the forms.
  1750.        If no user-defined function is desired, use the NO_BUTTON_FUNC
  1751.        macro in place of the function pointer in the last argument in
  1752.        FormSetButtonField().  The button field will just return the
  1753.        value assigned to it if NO_BUTTON_FUNC is used.  For example:
  1754.  
  1755.  
  1756.          Page 26          The C Window Library                 Page 26
  1757.  
  1758.        FormSetButtonField(form,entry,FORM_ACCEPT,"String",NO_BUTTON_FUNC)
  1759.  
  1760.        will return FORM_ACCEPT if the button field is accepted.
  1761.  
  1762.        If you do have a user-defined function, the normal return value,
  1763.        i.e. the third argument in FormSetButtonField() is ignored, and
  1764.        the return value for the user-defined function is used.
  1765.  
  1766.        Here are the possible return values that a button field can
  1767.        return to the form manager.  These return values are also used
  1768.        for the user-defined function (if it exists) that is bound to
  1769.        the button.
  1770.  
  1771.  
  1772.        Return Value                      Definition
  1773.        ------------                      ----------
  1774.  
  1775.        FIELD_PREVFIELD            Move input cursor to the previous
  1776.                                   field in the form and start editing
  1777.                                   from there.
  1778.  
  1779.        FIELD_NEXTFIELD            Move input cursor to the next field
  1780.                                   in the form and continue editing the
  1781.                                   next field.
  1782.  
  1783.        FIELD_CONTINUE_PROCESS     Do nothing and go on to the next
  1784.                                   field.
  1785.  
  1786.        FORM_CLEAR                 Clear the form and move input cursor
  1787.                                   to first available field.
  1788.  
  1789.        FORM_ACCEPT                Accept the current input in the form
  1790.                                   and exit.
  1791.  
  1792.        FIELD_NEWFIELD             Move cursor to a new field and
  1793.                                   continue editing from there.
  1794.  
  1795.        FORM_CANCEL                Do not accept any input that may have
  1796.                                   been previously entered and quit.
  1797.  
  1798.        FIELD_CONTINUE             Stay in the button field.
  1799.  
  1800.  
  1801.        The FIELD_PREVFIELD return value will move the input cursor to
  1802.        the previous field in the form.  If you try to move beyond the
  1803.        first available field on the form the FORM_WRAP and/or the
  1804.        FORM_EXIT_INITIAL form options will take action depending on
  1805.        whether they are on or off.  See CREATING FIELD ENTRIES for a
  1806.        definition of the FORM_WRAP and FORM_EXIT_INITIAL options.
  1807.  
  1808.        The FIELD_NEXTFIELD return value will move the input cursor to
  1809.        the next field in the form.  If you try to move beyond the first
  1810.        available field in the form, the FORM_WRAP form option will take
  1811.        action depending on whether this option was turned on.
  1812.  
  1813.        The FORM_CLEAR return value clears the form of all input data
  1814.        and moves the input cursor to the first available field.
  1815.  
  1816.          Page 27          The C Window Library                 Page 27
  1817.  
  1818.        The FORM_ACCEPT return value accepts all the input from the
  1819.        input fields and exits.  The form is not exited automatically if
  1820.        the FORM_CHECK option is on or if a field in the form has the
  1821.        FIELD_CHECK option on.  See CREATING FIELD ENTRIES for a
  1822.        definition of the FORM_CHECK and FIELD_CHECK options.
  1823.  
  1824.        The FORM_CANCEL rejects all input and exits the form.  The form
  1825.        is not automatically exited if there is an exit function defined
  1826.         for the form.  Form exit functions are discussed later in the
  1827.         manual.
  1828.  
  1829.        The FIELD_CONTINUE_PROCESS is a 'do nothing and go on to the
  1830.        next field' return value.  Use this return value if you want the
  1831.        button function to tell the form manager to go on to the next
  1832.        field (or previous field, depending on the direction that the
  1833.        input cursor was going).  This return value is usually used if
  1834.        there is a user-defined function defined, and only the side
  1835.        effects that the user function may do is of any concern.  For
  1836.        instance, the user-defined  function may display windows, and
  1837.        then return.  You would then return a FIELD_CONTINUE_PROCESS to
  1838.        the form manager to state that you do not want anything special
  1839.        to be done.
  1840.  
  1841.        The FIELD_NEWFIELD return value moves the input cursor to the
  1842.        field assigned to the pointer in the third argument of the
  1843.        user-defined function.  This return value can only be used if
  1844.        you have a user-defined function that is bound to the button
  1845.        field.  If you remember, the user-defined function's prototype
  1846.        passed a pointer to the current field number.  If you assign a
  1847.        field number to the dereferenced pointer and the FIELD_NEWFIELD
  1848.        return value is used, the form manager will move the input
  1849.        cursor to the field desired.  If the field entry does not exist,
  1850.        the form manager will not move the input cursor.  If the field
  1851.        is protected (FIELD_PROTECT flag is on) for the desired field,
  1852.        the input cursor is not moved.
  1853.  
  1854.        FIELD_CONTINUE returns control to the button field.  You cannot
  1855.        exit this field if it is accepted.  You can use this type of
  1856.        button field to implement help and display help information.
  1857.  
  1858.        Here is a small example of the CWL_BUTTON field:
  1859.  
  1860.        #include "cwlwin.h"
  1861.        #define REVERSE  CREATE_VIDEO_ATTRIBUTE(WHITE_,BLACK_)
  1862.        #define NORM     CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  1863.        /* initialize entries for form 1 */
  1864.        FIELD_ENTRY fentry[] = {CWL_BUTTON,0,0,"",' ',0,0,
  1865.                                        NO_FIELD_OPTIONS,0,0,"",
  1866.                                CWL_BUTTON,0,9,"",
  1867.                                        ' ',0,0,NO_FIELD_OPTIONS,0,
  1868.                                            0,"", FIELDEND};
  1869.        FORMPTR form;
  1870.        WPOINTER w;
  1871.        main()
  1872.        {
  1873.          int i;
  1874.          int attr[2];
  1875.  
  1876.          Page 28          The C Window Library                 Page 28
  1877.  
  1878.          WindowInitializeSystem();
  1879.          FormInitializeSystem();
  1880.          WindowInitDesktop(0);
  1881.          w = WindowInitialize(DESKTOP_WINDOW,BORDER,1,1,78,22,NORM,
  1882.                               NORM,SINGLEBOX);
  1883.          attr[NORMATTR] = NORM;
  1884.          attr[HIATTR] = REVERSE;
  1885.          /* Initialize form */
  1886.          form = FormInitialize(w,fentry,FORM_HIGHLIGHT);
  1887.  
  1888.          /* Let form know about button fields */
  1889.          FormSetButtonField(form,0,FIELD_NEXTFIELD,"Accept",attr,
  1890.                              NO_BUTTON_FUNC);
  1891.          FormSetButtonField(form,1,FORM_CANCEL,"Cancel",attr,
  1892.                              NO_BUTTON_FUNC);
  1893.          WindowWriteCenterString(w,
  1894.             "Use Left or Right Arrow Keys to move highlight",2);
  1895.          /* get the input */
  1896.          FormGetInput(form,1,0);
  1897.        }
  1898.  
  1899.        In the above example, two button fields are defined.  The row
  1900.        and column entries in the field description, fentry[], tells
  1901.        where the button field will be placed.  Note that the only
  1902.        meaningful entries in the CWL_BUTTON field are its row and
  1903.        column in the form, and the field options (the only option that
  1904.        can be used is FIELD_PROTECT).  All other arguments are
  1905.        meaningless (i.e. regular expression, starting input position,
  1906.        etc.).  The video attributes are derived from the array of
  1907.        attributes given in the FormSetButtonField() function.
  1908.  
  1909.        When the form encounters the first button, the highlight is
  1910.        moved to the position of the first button's prompt string.
  1911.        When the user hits the 'accept' key, the return value
  1912.        FIELD_NEXTFIELD is returned to the form manager, informing it to
  1913.        move the cursor to the next field.  A return value of
  1914.        FIELD_CONTINUE_PROCESS would have accomplished the same thing.
  1915.        The highlight is then moved to the next field, which is also a
  1916.        button field.  When the user accepts this field, the form is
  1917.        automatically exited.
  1918.  
  1919.        If there are no errors, FormSetButtonField() will return
  1920.        NO_ERROR.
  1921.  
  1922.        If there are errors the return value is one of the following
  1923.  
  1924.        UNDEFINED_FORM if the FORMPTR does not exist.
  1925.  
  1926.        UNDEFINED_FIELD if the field entry does not exist.
  1927.  
  1928.        NO_HEAP_MEM if there is not enough memory to allocate for the
  1929.        internal button data structure.
  1930.  
  1931.  
  1932.  
  1933.  
  1934.  
  1935.  
  1936.  
  1937.  
  1938.          Page 29          The C Window Library                 Page 29
  1939.  
  1940.        Radio Fields and the RADIO_ENTRY structure
  1941.        ------------------------------------------
  1942.        A radio field is a field that comprises a list of choices given
  1943.        to the user.  Only one of the choices can be chosen.  Usually a
  1944.        radio field is set up as a column and/or row of prompts with a
  1945.        'floating' character that goes from prompt to prompt when the
  1946.        user is selecting an option.  Unlike the CWL_LIST option, the
  1947.        radio field is not a popup menu, but is comprised of text
  1948.        written to the form window.
  1949.        To set up a radio field, the field type must be initialized to
  1950.        CWL_RADIO.  This is done when initializing the array of field
  1951.        entries.
  1952.  
  1953.        The next step is to initialize an array of RADIO_ENTRY
  1954.        structures.  Here is the layout for the RADIO_ENTRY structure:
  1955.  
  1956.        char *prompt         -  Prompt string to write to the form window.
  1957.  
  1958.        int hotkey_letter    -  Letter to highlight in prompt string.
  1959.  
  1960.        unsigned prompt_row  -  row to write the prompt string.
  1961.  
  1962.        unsigned prompt_col  -  column to write the prompt string.
  1963.  
  1964.        unsigned button_row  -  row to write the radio button character.
  1965.  
  1966.        unsigned button_col  -  column to write the radio button character.
  1967.  
  1968.        An array of these structures is needed to complete the total radio
  1969.        field definition.  Here is an example:
  1970.  
  1971.        RADIO_ENTRY radio_entry[] =
  1972.                        {"( ) Radio 1",'2',0,0,0,1, /* Radio Field 1 */
  1973.                         "( ) Radio 2",'2',1,0,1,1, /* Radio Field 2 */
  1974.                         "( ) Radio 3",'3',2,0,2,1, /* Radio Field 3 */
  1975.                         CWL_NULL};                 /* Terminator */
  1976.  
  1977.        Note that the variable radio_entry is an array of 3
  1978.        RADIO_ENTRY's.  The first entry is a string that will be written
  1979.        to the window.  In the example above the first RADIO_ENTRY's
  1980.        prompt string is "( ) Radio 1".  The next entry is the character
  1981.        to highlight in the prompt string.  This character will serve as
  1982.        a 'hotkey'.  When this character is pressed, the radio button
  1983.        character will automatically be placed at the desired choice.
  1984.        If no hotkey is desired, this entry should be 0.  The third and
  1985.        fourth entries are the (row,col) coordinates of where the prompt
  1986.        is placed in the form window.  The fifth and sixth entries are
  1987.        the (row,col) coordinates of the 'floating' character.  This
  1988.        character will be placed at the desired position when the user
  1989.        moves the highlight from entry to entry.  Note that the above
  1990.        example strategically placed the floating character in between
  1991.        the parentheses in each of the prompt strings.  This is the
  1992.        usual way to display a radio field, but you have the flexibility
  1993.        to design your own layouts.
  1994.  
  1995.        The array of RADIO_ENTRY's MUST be terminated with the CWL_NULL
  1996.        constant.  Leaving this out will cause unpredictable results.
  1997.  
  1998.          Page 30          The C Window Library                 Page 30
  1999.  
  2000.        Once the array of RADIO_ENTRY's has been set up, the next thing
  2001.        is to call the FormSetRadioField() function.  This function
  2002.        binds the RADIO_ENTRY's to the form, and defines attributes and
  2003.        the button character to use for the radio field.  Here is the
  2004.        prototype:
  2005.  
  2006.        int FormSetRadioField (FORMPTR form, int entry,
  2007.                               RADIO_ENTRY *rptr, int rchar,
  2008.                               int start, int *attr)
  2009.  
  2010.        The first two arguments are the form and the entry to assign the
  2011.        RADIO_ENTRY's to.  These must exist for the FormSetRadioField()
  2012.        function to succeed.  The third argument is the array of
  2013.        RADIO_ENTRY's that was set up previously.  The fourth argument
  2014.        is the character that will float from choice to choice when the
  2015.        user is deciding which selection to make.  The fifth argument is
  2016.        the starting entry to place the button character.  Entry numbers
  2017.        are numbered from 0 to the highest radio entry less one.  The
  2018.        last argument is an array of integers denoting the color
  2019.        attributes to use for the radio field.  Each element of this
  2020.        color array stands for a different aspect of the radio field.
  2021.        Here are the constants that denotes positions in the color
  2022.        array:
  2023.  
  2024.        NORMATTR - This is the color of the unhighlighted entry.
  2025.  
  2026.        HIATTR   - This is the color of the highlighted entry.  The
  2027.                   highlighted entry is the current entry that the user
  2028.                   has the choice of accepting.  The highlight is moved
  2029.                   from entry to entry when the user hits the
  2030.                   appropriate keys.  See GETTING INPUT FROM A FORM for
  2031.                   a discussion of these keys.
  2032.  
  2033.        HOTATTR  - This is the color of the hotkey.
  2034.  
  2035.        UNAVAILATTR - This is the attribute to use for unavailable radio
  2036.                      entries.  More on available and unavailable
  2037.                      entries later on.
  2038.  
  2039.        To initialize an array that is large enough to hold the
  2040.        attributes, Use the NUMRADIOCOLORS constant.  This constant
  2041.        holds the number of colors needed to define the radio field's
  2042.        color scheme.
  2043.  
  2044.        Here is a small example of using FormSetRadioField():
  2045.  
  2046.        #include "cwlwin.h"
  2047.        #define COLOR1 CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  2048.        #define COLOR2 CREATE_VIDEO_ATTRIBUTE(BLACK_,LIGHTWHITE_)
  2049.        #define COLOR3 COLOR2
  2050.        #define COLOR4 COLOR1
  2051.  
  2052.  
  2053.        RADIO_ENTRY radio_entry[] = {"( ) Radio 1",'1',0,0,0,1,
  2054.                                     "( ) Radio 2",'2',1,0,1,1,
  2055.                                     "( ) Radio 3",'3',2,0,2,1,
  2056.                                     CWL_NULL};
  2057.  
  2058.          Page 31          The C Window Library                 Page 31
  2059.  
  2060.        FORMPTR form;
  2061.        FIELD_ENTRY field[] = {CWL_RADIO,0,0,"",' ',
  2062.                               NO_FIELD_OPTIONS,0,0,"",FIELDEND};
  2063.  
  2064.        /* Initialize array of colors */
  2065.        int attr[NUMRADIOCOLORS];
  2066.  
  2067.        main()
  2068.        {
  2069.          int retval;
  2070.           /* Assume form is initialized */
  2071.  
  2072.          attr[NORMATTR]    = COLOR1;
  2073.          attr[HIATTR]      = COLOR2;
  2074.          attr[HOTATTR]     = COLOR3;
  2075.          attr[UNAVAILATTR] = COLOR4;
  2076.  
  2077.          retval = FormSetRadioField(form,0,radio_entry,7,0,attr);
  2078.          if (retval != NO_ERROR)
  2079.            /* some error message */
  2080.  
  2081.        }
  2082.  
  2083.        The above call to FormSetRadioField() uses the FORMPTR form and
  2084.        field entry 1 (this is the RADIO field).  The array,
  2085.        radio_entry, is used as the array of RADIO_ENTRY's.  The ASCII
  2086.        character 7 is used as the floating button character.  The IBM
  2087.        PC character set defines this as the 'bullet' character.  This
  2088.        character is usually used for radio fields, but you can use any
  2089.        ASCII character you desire (however, I highly recommend NOT
  2090.        using the space character!).  The fifth argument starts the
  2091.        radio button character on the first radio entry.
  2092.  
  2093.        If there are no errors, FormSetRadioField() and will return
  2094.        NO_ERROR.
  2095.  
  2096.        If there are errors the return value is one of the following
  2097.  
  2098.        UNDEFINED_FORM if the FORMPTR does not exist.
  2099.  
  2100.        UNDEFINED_FIELD if the field entry does not exist.
  2101.  
  2102.        NO_HEAP_MEM if there is not enough memory to allocate for the
  2103.        internal radio field data structure.
  2104.  
  2105.  
  2106.        Deactivating and Activating Radio Entries
  2107.        -----------------------------------------
  2108.  
  2109.        If FormSetRadioField() is successful, all of the radio entries
  2110.        are available for the user to choose from.  However, there may
  2111.        be situations where you may want some options disabled.  To
  2112.        disable radio entries use the FormDeactivateRadioEntry()
  2113.        function.  Here is the prototype to the function:
  2114.  
  2115.        int FormDeactivateRadioField(FORMPTR form, int entry,
  2116.                                     int radionum)
  2117.  
  2118.          Page 32          The C Window Library                 Page 32
  2119.  
  2120.        The first two arguments are the form and entry number of where
  2121.        to find the radio entry.  The last argument is the entry in the
  2122.        radio field to deactivate.  The reason for using the form and
  2123.        entry to find the radio field is that you can use the same radio
  2124.        field in different forms.  Therefore you must supply the form
  2125.        and entry number to find the radio field.  Once the radio entry
  2126.        is found, the prompt string for the desired radio entry takes on
  2127.        the UNAVAILATTR color.  Also this field is skipped automatically
  2128.        when the user is moving the button character from field to
  2129.        field.
  2130.  
  2131.        To reactivate a field, the FormActivateRadioEntry() function is
  2132.        used.  Here is the prototype:
  2133.  
  2134.        int FormActivateRadioEntry(FORMPTR form, int entry,
  2135.                                   int radionum)
  2136.  
  2137.        The arguments have the same definition as the
  2138.        FormDeactivateRadioEntry().  The radio entry is automatically
  2139.        given its NORMATTR color.
  2140.  
  2141.  
  2142.  
  2143.        Retrieving the Radio selection
  2144.        ------------------------------
  2145.  
  2146.        To find out what selection was made in the radio field, use the
  2147.        FormGetRadioChoice() function.  This function returns the number
  2148.        of the radio entry that was chosen.  Radio entries are numbered
  2149.        from 1 to the highest entry.  Entries are numbered as they are
  2150.        ordered in the RADIO_ENTRY array.  Here is the prototype to the
  2151.        function:
  2152.  
  2153.        int FormGetRadioChoice(FORMPTR form, int entry)
  2154.  
  2155.        The only arguments are the form and field entry where the radio
  2156.        field is defined.  Here is a small example:
  2157.  
  2158.        #include "cwlwin.h"
  2159.        #define COLOR1 CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  2160.        #define COLOR2 CREATE_VIDEO_ATTRIBUTE(BLACK_,LIGHTWHITE_)
  2161.        #define COLOR3 COLOR2
  2162.        #define COLOR4 COLOR1
  2163.  
  2164.        RADIO_ENTRY radio_entry[] = {"( ) Radio 1",'1',0,0,0,1,
  2165.                                     "( ) Radio 2",'2',1,0,1,1,
  2166.                                     "( ) Radio 3",'3',2,0,2,1,
  2167.                                     CWL_NULL};
  2168.        FORMPTR form;
  2169.        FIELD_ENTRY field[] = {CWL_RADIO,0,0,"",' ',0,0,
  2170.                               NO_FIELD_OPTIONS,0,0,"",FIELDEND};
  2171.  
  2172.        int attr[NUMRADIOCOLORS];
  2173.        WPOINTER w;
  2174.  
  2175.  
  2176.  
  2177.  
  2178.  
  2179.  
  2180.          Page 33          The C Window Library                 Page 33
  2181.  
  2182.        main()
  2183.        {
  2184.          WindowInitializeSystem();
  2185.          FormInitializeSystem();
  2186.          WindowInitDesktop(0);
  2187.  
  2188.          w = WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,78,22,COLOR1,
  2189.                               COLOR1,SINGLEBOX);
  2190.  
  2191.          /* Initialize form */
  2192.          form = FormInitialize(w,field,FORM_HIGHLIGHT|FORM_STATIC);
  2193.  
  2194.          attr[NORMATTR]    = COLOR1;
  2195.          attr[HIATTR]      = COLOR2;
  2196.          attr[HOTATTR]     = COLOR3;
  2197.          attr[UNAVAILATTR] = COLOR4;
  2198.  
  2199.          FormSetRadioField(form,0,radio_entry,7,0,attr);
  2200.          WindowWriteCenterString(w,
  2201.             "Hit TAB to accept, Up or Down Arrows to change choice",3);
  2202.          FormGetInput(form,1,0);
  2203.          WindowMoveCursor(w,4,19);
  2204.          VideoPrintf("The radio choice was %d",
  2205.                       FormGetRadioChoice(form,0));
  2206.        }
  2207.  
  2208.  
  2209.        The example above sets up a radio field, gets the input from the
  2210.        form, and then prints the radio entry that was chosen.  You can
  2211.        call the FormGetRadioChoice() at any time, even in user-defined
  2212.        functions that may be performed while the form is active.
  2213.  
  2214.        If successful, FormGetRadioChoice() returns the current radio
  2215.        entry that is chosen.  If all of the radio entries are
  2216.        deactivated, or the radio field is a protected field (no input
  2217.        will be accepted), the return value is -1.
  2218.  
  2219.        If there are errors the return value is one of the following
  2220.  
  2221.        UNDEFINED_FORM if the FORMPTR does not exist.
  2222.  
  2223.        UNDEFINED_FIELD if the field entry does not exist.
  2224.  
  2225.  
  2226.  
  2227.  
  2228.        Checkbox Fields and the CHECKBOX_ENTRY structure
  2229.        ------------------------------------------------
  2230.  
  2231.        A checkbox field is a field that comprises a list of choices
  2232.        given to the user.  Any number of these choices can be selected.
  2233.        This differs from the radio field defined above in that the
  2234.        radio fields only allowed one selection.
  2235.  
  2236.        To set up a checkbox field, the field type must be initialized
  2237.        to CWL_CHECKBOX.  This is done when initializing the array of
  2238.        field entries.
  2239.  
  2240.          Page 34          The C Window Library                 Page 34
  2241.  
  2242.        The next step is to initialize an array of CHECKBOX_ENTRY
  2243.        structures.  Here is the layout for the CHECKBOX_ENTRY
  2244.        structure:
  2245.  
  2246.        char *prompt         -  Prompt string to write to the form
  2247.                                window.
  2248.  
  2249.        int hotkey_letter    -  Letter to highlight in prompt string.
  2250.  
  2251.        unsigned prompt_row  -  row to write the prompt string.
  2252.  
  2253.        unsigned prompt_col  -  column to write the prompt string.
  2254.  
  2255.        unsigned button_row  -  row to write the checkbox button
  2256.                                character.
  2257.  
  2258.        unsigned button_col  -  column to write the checkbox button
  2259.                                character.
  2260.  
  2261.        An array of these structures is needed to complete the total
  2262.        checkbox field definition.  Here is an example:
  2263.  
  2264.        CHECKBOX_ENTRY checkbox_entry[] =
  2265.                {"[ ] Check 1",'1',0,0,0,1,  /* Checkbox field 1 */
  2266.                 "[ ] Check 2",'2',1,0,1,1,  /* Checkbox field 2 */
  2267.                 "[ ] Check 3",'3',2,0,2,1,  /* Checkbox field 3 */
  2268.                  CWL_NULL};                 /* Terminator */
  2269.  
  2270.        Note that the variable checkbox_entry is an array of 3
  2271.        CHECKBOX_ENTRY's.  The first entry is a string that will be
  2272.        written to the window.  In the example above the first
  2273.        CHECKBOX_ENTRY's prompt string is "[ ] Check 1".  The next entry
  2274.        is the character to highlight in the prompt string.  This
  2275.        character will serve as a 'hotkey'.  When this character is
  2276.        pressed, the checkbox button character will automatically be
  2277.        placed at the desired choice.  If no hotkey is desired, this
  2278.        entry should be 0.  The third and fourth entries are the
  2279.        (row,col) coordinates of where the prompt is placed in the form
  2280.        window.  The fifth and sixth entries are the (row,col)
  2281.        coordinates of the checkbox character.  This character will be
  2282.        placed at the desired position when the choice is selected.
  2283.        Note that the above example strategically placed the checkbox
  2284.        character in between the brackets in each of the prompt strings.
  2285.        This is the usual way to display a checkbox field, but you have
  2286.        the flexibility to design your own layouts.
  2287.  
  2288.        The array of CHECKBOX_ENTRY's MUST be terminated with the
  2289.        CWL_NULL constant.  Leaving this out will cause unpredictable
  2290.        results.  Once the array of CHECKBOX_ENTRY's has been set up,
  2291.        the next thing is to call the FormSetCheckboxField() function.
  2292.        This function binds the CHECKBOX_ENTRY's to the form, and
  2293.        defines attributes and the button character to use for the
  2294.        checkbox field.  Here is the prototype:
  2295.  
  2296.        int FormSetCheckboxField (FORMPTR form, int entry,
  2297.                               CHECKBOX_ENTRY cptr[], int cchar,
  2298.                               int start, int *attr)
  2299.  
  2300.          Page 35          The C Window Library                 Page 35
  2301.  
  2302.        The first two arguments are the form and the entry to assign the
  2303.        CHECKBOX_ENTRY's to.  These must exist for the FormSetCheckbox()
  2304.        function to succeed.  The third argument is the array of
  2305.        CHECKBOX_ENTRY's that was set up previously.  The fourth
  2306.        argument is the character that will be placed in when the entry
  2307.        is selected.  The fifth argument is the checkbox entry to place
  2308.        the cursor when the field is initially edited.   The last
  2309.        argument is an array of integers denoting the color attribute to
  2310.        use for the checkbox field.  Each element of this color array
  2311.        stands for a different aspect of the checkbox field.  Here are
  2312.        the constants that denotes positions in the color array:
  2313.  
  2314.        NORMATTR - This is the color of the unhighlighted entry.
  2315.  
  2316.        HIATTR   - This is the color of the highlighted entry.  The
  2317.                   highlighted entry is the current entry that the user
  2318.                   has the choice of accepting.  The highlight is moved
  2319.                   from entry to entry when the user hits the
  2320.                   appropriate keys.  See GETTING INPUT FROM A FORM for
  2321.                   a discussion of these keys.
  2322.  
  2323.        HOTATTR  - This is the color of the hotkey.
  2324.  
  2325.        UNAVAILATTR - This is the attribute to use for unavailable
  2326.                      checkbox entries.  More on available and
  2327.                      unavailable entries later on.
  2328.  
  2329.        To initialize an array that is large enough to hold the
  2330.        attributes, Use the NUMCHECKBOXCOLORS constant.  This constant
  2331.        holds the number of colors needed to define the checkbox field's
  2332.        color scheme.
  2333.  
  2334.        Here is a small example of using FormSetCheckboxField():
  2335.  
  2336.        #include "cwlwin.h"
  2337.        #define COLOR1 CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  2338.        #define COLOR2 CREATE_VIDEO_ATTRIBUTE(BLACK_,LIGHTWHITE_)
  2339.        #define COLOR3 COLOR2
  2340.        #define COLOR4 COLOR1
  2341.  
  2342.        CHECKBOX_ENTRY checkbox_entry[] = {"[ ] Check 1",'1',0,0,0,1,
  2343.                                           "[ ] Check 2",'2',1,0,1,1,
  2344.                                           "[ ] Check 3",'3',2,0,2,1,
  2345.                                           CWL_NULL};
  2346.  
  2347.        FORMPTR form;
  2348.        FIELD_ENTRY field[] = {CWL_CHECKBOX,0,0,"",' ',0,0,
  2349.                               NO_FIELD_OPTIONS, "", FIELDEND};
  2350.  
  2351.        int attr[NUMCHECKBOXCOLORS];
  2352.        WPOINTER w;
  2353.  
  2354.        main()
  2355.        {
  2356.          WindowInitializeSystem();
  2357.          FormInitializeSystem();
  2358.          WindowInitDesktop(0);
  2359.  
  2360.  
  2361.          Page 36          The C Window Library                 Page 36
  2362.  
  2363.          w = WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,78,22,COLOR1,
  2364.                               COLOR1,SINGLEBOX);
  2365.  
  2366.          /* Initialize form */
  2367.          form = FormInitialize(w,field,FORM_HIGHLIGHT);
  2368.  
  2369.          attr[NORMATTR]    = COLOR1;
  2370.          attr[HIATTR]      = COLOR2;
  2371.          attr[HOTATTR]     = COLOR3;
  2372.          attr[UNAVAILATTR] = COLOR4;
  2373.  
  2374.          FormSetCheckboxField(form,0,checkbox_entry,'X',0,attr);
  2375.  
  2376.        }
  2377.  
  2378.        The above call to FormSetCheckboxField() uses the FORMPTR form
  2379.        and field entry 0 (this is the CWL_CHECKBOX field).  The array,
  2380.        checkbox_entry, is used as the array of CHECKBOX_ENTRY's.  The
  2381.        'X' character is used as the checkbox character.  This character
  2382.        is usually used for checkbox fields, but you can use any ASCII
  2383.        character you desire (as stated before, I highly recommend NOT
  2384.        using the space character!).
  2385.  
  2386.        If there are no errors, FormSetCheckboxField() and will return
  2387.        NO_ERROR.
  2388.  
  2389.        If there are errors the return value is one of the following
  2390.  
  2391.        UNDEFINED_FORM if the FORMPTR does not exist.
  2392.  
  2393.        UNDEFINED_FIELD if the field entry does not exist.
  2394.  
  2395.        NO_HEAP_MEM if there is not enough memory to allocate for the
  2396.        internal checkbox field data structure.
  2397.  
  2398.  
  2399.  
  2400.        Deactivating and Activating Checkbox Entries
  2401.        --------------------------------------------
  2402.  
  2403.        If FormSetCheckboxField() is successful, all of the checkbox
  2404.        entries are available for the user to choose from.  However,
  2405.        there may be situations where you may want some options
  2406.        disabled.  To disable checkbox entries use the
  2407.        FormDeactivateCheckboxEntry() function.  Here is the prototype
  2408.        to the function:
  2409.  
  2410.        int FormDeactivateCheckboxField(FORMPTR form, int entry,
  2411.                                        int checkboxnum)
  2412.  
  2413.        The first two arguments are the form and entry number of where
  2414.        to find the checkbox entry.  The last argument is the entry in
  2415.        the checkbox field to deactivate.  The reason for using the form
  2416.        and entry to find the checkbox field is that you can use the
  2417.        same checkbox field in different forms.  Therefore you must
  2418.        supply the
  2419.  
  2420.  
  2421.          Page 37          The C Window Library                 Page 37
  2422.  
  2423.        form and entry number to find the checkbox field.  Once the
  2424.        checkbox entry is found, the prompt string for the desired
  2425.        checkbox entry takes on the UNAVAILATTR color.
  2426.  
  2427.        To reactivate a field, the FormActivateCheckboxEntry() function
  2428.        is used.  Here is the prototype:
  2429.  
  2430.        int FormActivateCheckboxEntry(FORMPTR form, int entry,
  2431.                                      int checkboxnum)
  2432.  
  2433.        The arguments have the same definition as the
  2434.        FormDeactivateCheckboxEntry().  The checkbox entry is
  2435.        automatically given its NORMATTR color.
  2436.  
  2437.  
  2438.        Retrieving the checkbox selection
  2439.        ---------------------------------
  2440.  
  2441.        To find out whether a checkbox entry was selected, use the
  2442.        FormGetCheckboxChoice() function.  This function returns 1 if
  2443.        the entry is selected, 0 otherwise.  Checkbox entries are
  2444.        numbered from 1 to the highest entry.  Entries are numbered as
  2445.        they are ordered in the CHECKBOX_ENTRY array.  Here is the
  2446.        prototype to the function:
  2447.  
  2448.        int FormGetCheckboxChoice(FORMPTR form, int entry, int cboxentry)
  2449.  
  2450.        The arguments are the form and field entry where the checkbox
  2451.        field is defined.  The last argument is the checkbox entry to
  2452.        test to see if it was selected.  Here is a small example:
  2453.  
  2454.        #include "cwlwin.h"
  2455.        #define COLOR1 CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  2456.        #define COLOR2 CREATE_VIDEO_ATTRIBUTE(BLACK_,LIGHTWHITE_)
  2457.        #define COLOR3 COLOR2
  2458.        #define COLOR4 COLOR1
  2459.  
  2460.        CHECKBOX_ENTRY checkbox_entry[] = {"[ ] Check 1",'1',0,0,0,1,
  2461.                                           "[ ] Check 2",'2',1,0,1,1,
  2462.                                           "[ ] Check 3",'3',2,0,2,1,
  2463.                                           CWL_NULL};
  2464.        FORMPTR form;
  2465.        FIELD_ENTRY field[] = {CWL_CHECKBOX,0,0,"",' ',0,0,
  2466.                               NO_FIELD_OPTIONS,0,0,"", FIELDEND};
  2467.  
  2468.        int attr[NUMCHECKBOXCOLORS];
  2469.        WPOINTER w;
  2470.  
  2471.        main()
  2472.        {
  2473.          int i;
  2474.          WindowInitializeSystem();
  2475.          FormInitializeSystem();
  2476.          WindowInitDesktop(0);
  2477.  
  2478.  
  2479.  
  2480.  
  2481.          Page 38          The C Window Library                 Page 38
  2482.  
  2483.          w = WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,78,22,COLOR1,
  2484.                               COLOR1,SINGLEBOX);
  2485.  
  2486.          /* Initialize form */
  2487.          form = FormInitialize(w,field,FORM_HIGHLIGHT|FORM_STATIC);
  2488.  
  2489.          attr[NORMATTR]    = COLOR1;
  2490.          attr[HIATTR]      = COLOR2;
  2491.          attr[HOTATTR]     = COLOR3;
  2492.          attr[UNAVAILATTR] = COLOR4;
  2493.  
  2494.          FormSetCheckboxField(form,0,checkbox_entry,'X',0,attr);
  2495.          WindowWriteCenterString(w,
  2496.         "Hit TAB to accept, Space Bar to toggle, Arrow keys to change"
  2497.             "choice",3);
  2498.  
  2499.          FormGetInput(form,1,0);
  2500.          WindowMoveCursor(w,5,0);
  2501.          for (i=0; i<3; i++)
  2502.            VideoPrintf("Checkbox choice %d was %s chosen\n",i,
  2503.                         FormGetCheckboxChoice(form,1,i)?"":"not");
  2504.        }
  2505.  
  2506.        The example above sets up a checkbox field, gets the input from
  2507.        the form, and then loops to see if any checkboxes were selected.
  2508.        The string "not" is printed if FormGetCheckboxChoice() returns
  2509.        0, else an empty string is printed.  FormGetCheckboxChoice() can
  2510.        be called at any time, even in user-defined functions that may
  2511.        be performed while the form is active.
  2512.  
  2513.        FormGetCheckboxChoice() returns 1 if the choice was selected, 0
  2514.        otherwise.
  2515.  
  2516.        If there are errors the return value is one of the following
  2517.  
  2518.        UNDEFINED_FORM if the FORMPTR does not exist.
  2519.  
  2520.        UNDEFINED_FIELD if the field entry does not exist.
  2521.  
  2522.  
  2523.  
  2524.  
  2525.  
  2526.  
  2527.  
  2528.  
  2529.  
  2530.  
  2531.  
  2532.  
  2533.  
  2534.  
  2535.  
  2536.  
  2537.  
  2538.  
  2539.  
  2540.  
  2541.          Page 39          The C Window Library                 Page 39
  2542.  
  2543.                         GETTING INPUT FROM A FORM
  2544.                         -------------------------
  2545.  
  2546.        The following section discusses how to call functions that
  2547.        process the input form.
  2548.  
  2549.  
  2550.        FormGetInput()
  2551.        --------------
  2552.  
  2553.        The FormGetInput() function processes a form.  Here is a
  2554.        prototype:
  2555.  
  2556.        int FormGetInput(FORMPTR form, int rank, int start)
  2557.  
  2558.                                        or
  2559.  
  2560.        int FormGetInput(FORMPTR form, int rank, int start, WPOINTER w)
  2561.  
  2562.  
  2563.        The first prototype is for non-virtual forms (regular windows
  2564.        are used).
  2565.  
  2566.        The second prototype is for virtual forms.  The second
  2567.        prototype's last argument is a pointer to window.  This window
  2568.        is the viewport that is currently assigned to the virtual window
  2569.        used to initialize the FIELD_ENTRY's.  This parameter is
  2570.        necessary since the form manager only knows what the virtual
  2571.        window is, and has no record of the viewport (since a virtual
  2572.        window can have multiple viewports).
  2573.  
  2574.        The first argument to FormGetInput() is the pointer to a form.
  2575.        This form must have been previously initialized with
  2576.        FormInitialize().
  2577.  
  2578.        The second argument is the rank of the window the form is going
  2579.        to be displayed on.
  2580.  
  2581.        The third argument is the field entry to start the input from.
  2582.        Field entries are numbered from 0 to the highest field defined
  2583.        in the form less one.  If the field is protected, a circular
  2584.        search for the next available field is done.  For example , if
  2585.        there are 6 fields, and field 4 is protected, field 5 is the
  2586.        next available field.  However if field 5 is protected, field 0
  2587.        is the next available field.
  2588.  
  2589.        The fourth argument, as discussed above, is an optional
  2590.        argument.  This argument must be used if you are using a virtual
  2591.        form.
  2592.  
  2593.        If there are no errors, FormGetInput() returns NO_ERROR.
  2594.  
  2595.        If there are errors, FormGetInput() returns one of the following
  2596.        and sets window_error_code to one these values:
  2597.  
  2598.        UNDEFINED_FORM if the FORMPTR does not exist.
  2599.  
  2600.        BAD_WINDOW if the viewport window does not exist.
  2601.  
  2602.          Page 40          The C Window Library                 Page 40
  2603.  
  2604.        #include "cwlwin.h"
  2605.        #define NORM  CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  2606.  
  2607.        FIELD_ENTRY field_array[] =
  2608.  
  2609.                /* define first field entry */
  2610.  
  2611.                {CWL_INTEGER,0,19,"___",'_',1,3,FIELD_RJUSTIFY,NORM,0,
  2612.                 "3[0-9]",
  2613.                CWL_STRING, 1, 19, "__________", '_', 0, 10,
  2614.                  NO_FIELD_OPTIONS, 0,NORM, "10.",
  2615.                CWL_INTEGER,2, 19, "__", '_', 2, 2,NO_FIELD_OPTIONS,
  2616.                  0,NORM, "2[0-9]",
  2617.                CWL_DOUBLE,3, 19, "_______",'_',1,7,
  2618.                  FIELD_COMMA|FIELD_LJUSTIFY,0,NORM,"7[0-9/.]",
  2619.                CWL_CHAR, 4, 19,"_", '_', 1, 1, FIELD_UPPERCASE, 0,NORM,
  2620.                "[YyNn]",
  2621.                FIELDEND};
  2622.  
  2623.        WPOINTER w;
  2624.        FORMPTR form;
  2625.        main()
  2626.        {
  2627.          WindowInitializeSystem();
  2628.          FormInitializeSystem();
  2629.          FormInitializeFloat();
  2630.          WindowInitDesktop(0);
  2631.          w = WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,40,10,NORM,
  2632.                               NORM,SINGLEBOX);
  2633.          /* Initialize with WPOINTER */
  2634.  
  2635.          form = FormInitialize(w,  /* window to assign form to */
  2636.                                field_array, /* array of fields */
  2637.                                NO_FORM_OPTIONS); /* form options */
  2638.          if (form == FORM_NULL_PTR)
  2639.          {
  2640.            printf("Form could not be initialized");
  2641.            exit(0);
  2642.          }
  2643.          FormGetInput(form,1,0);   /* Get Input for the form */
  2644.        }
  2645.  
  2646.        Virtual Form Scrolling
  2647.        ----------------------
  2648.  
  2649.        If the form is a virtual form, the form is scrolled
  2650.        automatically to the desired field if the field is not currently
  2651.        in the viewport.  If the form has to be scrolled up or down, the
  2652.        field will come into view on the last line of the viewport or
  2653.        the first line, depending on whether the form was scrolled up or
  2654.        down to bring the field into view.
  2655.  
  2656.        If the form has to be scrolled left or right to bring the field
  2657.        in view, the field will either be brought in so that it is right
  2658.        justified in the viewport, or will appear on the left edge of
  2659.        the viewport depending on whether the form manager had to scroll
  2660.        the form left or right.
  2661.  
  2662.          Page 41          The C Window Library                 Page 41
  2663.  
  2664.        Editing Input
  2665.        -------------
  2666.        When getting input from a form, the following key definitions
  2667.        are used as the defaults:
  2668.  
  2669.                                                  Offset in Key
  2670.        Function                     Key             Table
  2671.        --------                     ---          -------------
  2672.        Move cursor left         Left Arrow     FIELD_MOVELEFT_KEY
  2673.  
  2674.        Move cursor right        Right Arrow    FIELD_MOVERIGHT_KEY
  2675.  
  2676.        Delete character         Del            FIELD_DELNOMOVE_KEY
  2677.  
  2678.        Toggle Insert/Overwrite  Insert         FIELD_INSTOGGLE_KEY
  2679.  
  2680.        Erase Input              ^E             FIELD_ERASE_KEY
  2681.  
  2682.        Destructive backspace    Backspace      FIELD_BACKSPACE_KEY
  2683.  
  2684.        Accept Input and goto    Enter          FIELD_ACCEPT_KEY
  2685.        next field.
  2686.  
  2687.        Accept default and       Not Assigned   FIELD_ACCEPTDEFAULT_KEY
  2688.        return
  2689.  
  2690.        Go to first column       Home           FIELD_HOME_KEY
  2691.  
  2692.        Move cursor to last      End            FIELD_END_KEY
  2693.        character
  2694.  
  2695.        Go to previous field     Up Arrow       FIELD_PREVFIELD_KEY
  2696.  
  2697.        Go to next field         Down Arrow     FIELD_NEXTFIELD_KEY
  2698.  
  2699.        Toggle Field             Space Bar      FIELD_TOGGLE_KEY
  2700.  
  2701.        Button Accept key        Enter          BUTTON_ACCEPT_KEY
  2702.  
  2703.        Button Move to next      Right Arrow    BUTTON_NEXTFIELD_KEY
  2704.        field
  2705.  
  2706.        Button Move to prev      Left Arrow     BUTTON_PREVFIELD_KEY
  2707.        field
  2708.  
  2709.        Move Radio button to     Down  Arrow    RADIO_NEXTENTRY_KEY
  2710.        next entry
  2711.  
  2712.        Move Radio button to     Up   Arrow     RADIO_PREVENTRY_KEY
  2713.        previous entry
  2714.  
  2715.  
  2716.        Move to next field from  Tab            RADIO_NEXTFIELD_KEY
  2717.        radio field
  2718.  
  2719.        Move to previous field   ShiftTab       RADIO_PREVFIELD_KEY
  2720.        from radio field
  2721.  
  2722.          Page 42          The C Window Library                 Page 42
  2723.  
  2724.        Select/deselect           Space Bar     CHECKBOX_CHOICE_KEY
  2725.        checkbox entry
  2726.  
  2727.        Move checkbox cursor to   Down  Arrow   CHECKBOX_NEXTENTRY_KEY
  2728.        next checkbox entry
  2729.  
  2730.        Move checkbox cursor to   Up   Arrow    CHECKBOX_PREVENTRY_KEY
  2731.        previous checkbox entry
  2732.  
  2733.        Move to next field from   Tab           CHECKBOX_NEXTFIELD_KEY
  2734.        checkbox field
  2735.  
  2736.        Move to previous field    ShiftTab      CHECKBOX_PREVFIELD_KEY
  2737.        checkbox field
  2738.  
  2739.        Accept form               ^S            FORM_EXIT_ACCEPT_KEY
  2740.  
  2741.        Escape form               Escape        FORM_CANCEL_KEY
  2742.  
  2743.        Clear Form                ^End          FORM_CLEAR_KEY
  2744.  
  2745.        Here is a list of what the key functions perform:
  2746.  
  2747.  
  2748.        Move cursor left - Moves the cursor left one character.  If the
  2749.                           beginning of the input field is encountered
  2750.                           the cursor is not moved.
  2751.  
  2752.        Move cursor right - Moves the cursor right one character.  If
  2753.                            the end of the input field is encountered,
  2754.                            the cursor is not moved.
  2755.  
  2756.        Delete character at cursor - Deletes the character at the
  2757.                                     position of the cursor.  If in
  2758.                                     insert mode, any input to the right
  2759.                                     of the cursor is moved one
  2760.                                     character to the left.  If in
  2761.                                     overwrite mode, no characters are
  2762.                                     moved.
  2763.  
  2764.        Toggle Insert/Overwrite Mode - toggles the input between insert
  2765.                                     and overwrite mode.  If in insert
  2766.                                       mode, the default cursor is an
  2767.                                       underline cursor.  If in
  2768.                                       overwrite mode, the default
  2769.                                       cursor is a full block.
  2770.  
  2771.        Erase Input - Deletes all characters inputted and moves the
  2772.                      cursor to the first input position.
  2773.  
  2774.        Destructive Backspace - deletes the character immediately to the
  2775.                                left of the cursor and moves the cursor
  2776.                                to the left one character. If insert
  2777.                                mode is on, the characters from the
  2778.                                current cursor position to the end of
  2779.                                the input field are also moved.
  2780.  
  2781.  
  2782.          Page 43          The C Window Library                 Page 43
  2783.  
  2784.        Accept string - Accepts the string that is inputted and returns
  2785.                        the string.  Also goes to next field by default.
  2786.  
  2787.        Accept default and return - Returns the default string given to
  2788.                                    the input routine.
  2789.  
  2790.        Go to first column in field - Moves cursor to the first input
  2791.                                      position.
  2792.  
  2793.        Go to last character in field - Moves cursor to the last
  2794.                                        character in the current input
  2795.                                        string.
  2796.  
  2797.        Go to previous field - Moves input cursor to the first character
  2798.                        in the previous field.  If field is field 1 or
  2799.                               first available field, the input cursor
  2800.                               is moved to the last input field if the
  2801.                               FORM_WRAP option is on, otherwise the
  2802.                               input cursor is not moved.
  2803.  
  2804.        Go to next field - Moves the input cursor to the first character
  2805.                           in the next field in sequence.
  2806.  
  2807.        Toggle field     - Displays next choice in a CWL_TOGGLE field.
  2808.                           Only is active for CWL_TOGGLE field.
  2809.                           Undefined for other fields.
  2810.  
  2811.        Button Accept    - Accepts the CWL_BUTTON field and will perform
  2812.                           whatever the buttons return value was.
  2813.  
  2814.        Button Move to next field  - Moves to the next field from a
  2815.                                     button Does not accept the button
  2816.                                     field.
  2817.  
  2818.        Button move to prev. field  - Moves to previous field from a
  2819.                                      button field.  Does not accept the
  2820.                                      button field.
  2821.  
  2822.        Move Radio button to next radio entry - moves the highlight in
  2823.                                                the radio entry to the
  2824.                                                next available radio
  2825.                                                entry.
  2826.  
  2827.        Move Radio button to prev. radio entry - moves the highlight in
  2828.                                                 the radio entry to the
  2829.                                                 previous radio entry.
  2830.  
  2831.        Move to next field from radio - moves to the next field from a
  2832.                                        radio field.
  2833.  
  2834.        Move to prev. field from radio - moves to the previous field
  2835.                                        from a radio field.
  2836.  
  2837.        Select/Deselect checkbox entry - toggles checkbox entry for
  2838.                                         selection/delection.
  2839.  
  2840.  
  2841.  
  2842.          Page 44          The C Window Library                 Page 44
  2843.  
  2844.        Move to next checkbox entry - moves the highlight to the next
  2845.                                      checkbox entry.
  2846.  
  2847.        Move to prev. checkbox entry - moves the highlight to the
  2848.                                      previous checkbox entry.
  2849.  
  2850.        Move to next field from checkbox - moves to the next field from
  2851.                                           a checkbox field.
  2852.  
  2853.        Move to prev. field from checkbox - moves to the previous field
  2854.                                            from a checkbox field.
  2855.  
  2856.        Accept form -      Accepts the input to a form, and exits
  2857.                           processing the form.
  2858.  
  2859.        Escape form and do not accept - Exits form without accepting the
  2860.                                        input to any fields.
  2861.  
  2862.        Clear Form - clears all input in a form and moves the cursor to
  2863.                                        the first available field.
  2864.  
  2865.  
  2866.        Changing the Editing Key definitions globally using the
  2867.        CWLform_edit_key table
  2868.        ----------------------
  2869.        You can change the key definitions globally (all fields will
  2870.        have the same key definitions) by changing the CWLform_edit_key
  2871.        array of values.  The mapped position is the offset in a table
  2872.        of field key functions.  By changing the value there, you can
  2873.        change the keys used to perform these functions.  If you do want
  2874.        to change these keys, I recommend using the key definitions
  2875.        found in the keycodes.h file.  For example, if you wanted tab
  2876.        key to be the advance to next field key you would do the
  2877.        following:
  2878.  
  2879.                CWLform_edit_key[FIELD_NEXTFIELD_KEY] = TAB;
  2880.  
  2881.        The table of key functions is stored in the array
  2882.        CWLform_edit_key.  The TAB definition is found in the keycodes.h
  2883.        file.  To totally undefine a key definition, assign a 0 to the
  2884.        desired array position in window_edit_key.  For example:
  2885.  
  2886.                CWLform_edit_key[FIELD_DELNOMOVE_KEY] = 0;
  2887.  
  2888.        undefines the delete character at cursor definition.
  2889.  
  2890.        When changing keys, make sure that the definitions all have
  2891.        unique key combinations.  If you desire more keystrokes for a
  2892.        particular key function, see Undefined Form Keystroke Processing
  2893.        below.
  2894.  
  2895.  
  2896.        Changing the Editing Key definitions using FormAssignFieldKeys()
  2897.        ----------------------------------------------------------------
  2898.  
  2899.        The FormAssignFieldKeys() assigns a key definition to a
  2900.        particular field.  In other words, each field can have its own
  2901.  
  2902.          Page 45          The C Window Library                 Page 45
  2903.  
  2904.        set of editing key definitions.  Here is the prototype:
  2905.  
  2906.        int FormAssignFieldKeys(FORMPTR form, int entrynum,
  2907.                                unsigned *keydef)
  2908.  
  2909.        The first argument is the pointer to the form.  The form must
  2910.        have been successfully initialized with FormInitialize().
  2911.  
  2912.        The second argument is the field entry number to assign these
  2913.        key definitions to.  As stated before, entry numbers are labeled
  2914.        from 0 to the highest entry number in the form less one.
  2915.  
  2916.        The third argument is an array of key definitions.  This array
  2917.        must be analogous to the CWLform_edit_key array.
  2918.  
  2919.        Example:
  2920.  
  2921.        #include "cwlwin.h"
  2922.        #include <string.h>
  2923.  
  2924.        /*  ...  define everything ... */
  2925.  
  2926.        unsigned newkeys[NUMFORMKEYS];
  2927.        FORMPTR form;
  2928.        FIELD_ENTRY field_entry[] = { /* .. Field definitions ... */ };
  2929.        WPOINTER w;
  2930.  
  2931.        main()
  2932.        {
  2933.          WindowInitializeSystem();
  2934.          FormInitializeSystem();
  2935.        /* ... assume Form Initialization stuff has been done ... */
  2936.  
  2937.        /* copy old key definitions to the new array */
  2938.          memcpy(newkeys,CWLform_edit_key,sizeof(CWLform_edit_key));
  2939.  
  2940.        /* assign desired keys */
  2941.          newkeys[FIELD_NEXT_KEY] = TAB;
  2942.          newkeys[FIELD_PREV_KEY] = SHIFTTAB;
  2943.  
  2944.        /* Assign this key definition to second field entry */
  2945.          FormAssignFieldKeys(form,1,newkeys);
  2946.        }
  2947.  
  2948.  
  2949.        Note that the constant NUMFORMKEYS was used to make sure that
  2950.        our newkeys array was large enough to hold all the key
  2951.        definitions.  Also note the shortcut that was taken with the
  2952.        memcpy() function.  This copied all the old key definitions to
  2953.        the newkeys array.  Both the newkeys array and the
  2954.        CWLform_edit_key array are guaranteed to be the same size if the
  2955.        constant NUMFORMKEYS is used.
  2956.  
  2957.        If there are no errors, FormAssignFieldKeys() returns NO_ERROR.
  2958.  
  2959.        If there are errors, FormAssignFieldKeys() returns one of the
  2960.        following and sets window_error_code to one these values:
  2961.  
  2962.          Page 46          The C Window Library                 Page 46
  2963.  
  2964.        UNDEFINED_FORM if the FORMPTR does not exist.
  2965.  
  2966.        UNDEFINED_FIELD if the field entry does not exist
  2967.  
  2968.        Traversing fields and the FORM_HIGHLIGHT option
  2969.        -----------------------------------------------
  2970.  
  2971.        When going from field to field, you can have each field take on
  2972.        the field color only when they are the active field (field
  2973.        currently being input).  This will happen if the FORM_HIGHLIGHT
  2974.        option is on.  If the field is not the active field, the field
  2975.        takes on the same color as the window or the viewport text
  2976.        color.
  2977.  
  2978.        If the FORM_HIGHLIGHT option is off, each field will take on its
  2979.        field color even if they are not the current field.
  2980.  
  2981.  
  2982.  
  2983.  
  2984.  
  2985.  
  2986.  
  2987.  
  2988.  
  2989.  
  2990.  
  2991.  
  2992.  
  2993.  
  2994.  
  2995.  
  2996.  
  2997.  
  2998.  
  2999.  
  3000.  
  3001.  
  3002.  
  3003.  
  3004.  
  3005.  
  3006.  
  3007.  
  3008.  
  3009.  
  3010.  
  3011.  
  3012.  
  3013.  
  3014.  
  3015.  
  3016.  
  3017.  
  3018.  
  3019.  
  3020.  
  3021.  
  3022.          Page 47          The C Window Library                 Page 47
  3023.  
  3024.              ASSIGNING VALUES TO AND RETRIEVING VALUES FROM A FORM
  3025.              -----------------------------------------------------
  3026.  
  3027.        When you edit an input field, you are entering just a string of
  3028.        characters.  The C Window Library's form manager will
  3029.        automatically convert these strings to the correct data type,
  3030.        and assign these values to specified variables when a form is
  3031.        exited, or whenever you want to retrieve the data.
  3032.  
  3033.        The field type determines what type of conversion will be done.
  3034.        The supported types are the normal C types.  The CWL_SUBFORM,
  3035.        CWL_VSUBFORM, CWL_BUTTON, CWL_RADIO, and CWL_CHECKBOX fields do
  3036.        not have a return type.  The CWL_LIST field returns the string
  3037.        in the popup menu that was selected.  The CWL_TOGGLE field
  3038.        returns the string that was chosen in the toggle field list.
  3039.  
  3040.  
  3041.        FormSetFieldVariable()
  3042.        ----------------------
  3043.  
  3044.        The FormSetFieldVariable() function assigns a variable to a
  3045.        particular field in a form.  When the form is exited, the data
  3046.        is converted and transferred to the variable specified.  Here is
  3047.        the prototype:
  3048.  
  3049.        int FormSetFieldVariable(FORMPTR form, int entrynum,
  3050.                                     void *uservar, int display)
  3051.  
  3052.        The first argument is the pointer to a form.
  3053.        The second argument is the field entry to assign the user
  3054.        variable to.
  3055.  
  3056.        The third argument is a pointer to the user variable.  The
  3057.        fourth argument is a flag to tell the form manager whether to
  3058.        display the value in the variable on the form.  If display is
  3059.        TRUE, the variable's value is automatically displayed in the
  3060.        form.  If display is FALSE, the variable's value is not
  3061.        displayed in the form.  No matter what the last argument is, the
  3062.        address of the variable is assigned to the form.
  3063.  
  3064.        If the field type is CWL_TOGGLE, this type translates to a
  3065.        string type because a string will ultimately be displayed in the
  3066.        field when a selection is made.  CWL_SUBFORM's, CWL_VSUBFORM's,
  3067.        CWL_BUTTON's, CWL_RADIO's, CWL_CHECKBOXes and CWL_LIST's have no
  3068.        corresponding C data type, therefore you cannot assign a
  3069.        variable to these field types.
  3070.  
  3071.        Example:
  3072.  
  3073.        #include "cwlwin.h"
  3074.        #include <string.h>
  3075.  
  3076.        #define NORM   CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  3077.        #define REVERSE CREATE_VIDEO_ATTRIBUTE(_WHITE,_BLACK)
  3078.  
  3079.        FORMPTR form;
  3080.  
  3081.  
  3082.  
  3083.          Page 48          The C Window Library                 Page 48
  3084.  
  3085.        FIELD_ENTRY field_entry[] =
  3086.        {CWL_INTEGER,0,19,"_____",' ',1,5,NO_FIELD_OPTIONS,0,
  3087.                         REVERSE,"5[0-9]",
  3088.         CWL_ULINTEGER,1,19,"_________",' ',1,9,NO_FIELD_OPTIONS,
  3089.                         0,REVERSE,"9[0-9]",FIELDEND};
  3090.  
  3091.        WPOINTER w;
  3092.        main()
  3093.        {
  3094.          int intvar = 123;  /* define integer and long variables */
  3095.          unsigned long lvar = 456L;
  3096.          WindowInitializeSystem();
  3097.          FormInitializeSystem();
  3098.          WindowInitDesktop(0);
  3099.          w = WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,60,4,NORM,
  3100.                               NORM,SINGLEBOX);
  3101.  
  3102.          form = FormInitialize(w,field_entry,FORM_HIGHLIGHT);
  3103.  
  3104.          /* Set user variables */
  3105.          FormSetFieldVariable(form,0,&intvar,TRUE);
  3106.          FormSetFieldVariable(form,1,&lvar,TRUE);
  3107.  
  3108.          FormGetInput(form,1,0);
  3109.  
  3110.          VideoPrintf(
  3111.          "The value of intvar is %d.\nThe value of lvar is %ul",
  3112.              intvar,lvar);
  3113.        }
  3114.  
  3115.        When the form is exited, the variables intvar and lvar have the
  3116.        values automatically converted.
  3117.  
  3118.        If you change the value of a variable that is assigned to a
  3119.        field, the field is not updated.  Use the FormPutFieldData() to
  3120.        change the value of a field.
  3121.  
  3122.        Warning!  You must make sure that you assign the pointer to a
  3123.        variable of the correct type.  If not, you may overwrite memory
  3124.        when the conversion takes place.
  3125.  
  3126.  
  3127.        Placing input in a form with FormPutFieldData()
  3128.        -----------------------------------------------
  3129.  
  3130.        You can write the value of a variable or an expression to a
  3131.        field at anytime using the FormPutFieldData() function.  Here is
  3132.        the prototype:
  3133.  
  3134.        int FormPutFieldData(FORMPTR form, int entry, ...)
  3135.  
  3136.        The first argument is the form, and the second is the entry
  3137.        number.  The last argument third is the value to write to the
  3138.        field.  Note that the ellipses are used when prototyping the
  3139.        last argument.  The reason for this is that the variable or
  3140.        expression can be of any type, therefore the undefined third
  3141.        argument.
  3142.  
  3143.          Page 49          The C Window Library                 Page 49
  3144.  
  3145.        You should make sure that the variable/expression translates to
  3146.        the same data type as the field type.  There is no harm done if
  3147.        you have an expression of a different type than the field, but
  3148.        you may get weird characters in the field when it is displayed.
  3149.  
  3150.        Here is an example:
  3151.  
  3152.        #include "cwlwin.h"
  3153.  
  3154.        /* assume everything is initialized */
  3155.  
  3156.        main()
  3157.        {
  3158.          int intvar = 0;
  3159.          long lvar  = 2;
  3160.  
  3161.          /*...*/
  3162.          FormPutFieldData(form,0,intvar); /* place value of intvar in
  3163.                                              entry 1 */
  3164.          FormPutFieldData(form,1,lvar);   /* place value of lvar in
  3165.                                              entry 2 */
  3166.          FormPutFieldData(form,0,3+5*6); /* place value of expression
  3167.                                             in entry 1 */
  3168.          /* ... */
  3169.        }
  3170.  
  3171.        If there are errors, FormPutFieldData() returns one of the
  3172.        following and sets window_error_code to one these values:
  3173.  
  3174.        UNDEFINED_FORM if the FORMPTR does not exist.
  3175.  
  3176.        UNDEFINED_FIELD if the field entry does not exist
  3177.  
  3178.  
  3179.        Retrieving Input with FormGetFieldData()
  3180.        ----------------------------------------
  3181.  
  3182.        You can retrieve and convert the string entered in a field at
  3183.        any time, including if the form has been exited, with the
  3184.        FormGetFieldData() function.  Here is the prototype:
  3185.  
  3186.        int FormGetFieldData(FORMPTR form, int entrynum, void *uservar)
  3187.  
  3188.        The first and second arguments are the form and field entry
  3189.        number, respectively.
  3190.  
  3191.        The third argument is the pointer to the desired variable to
  3192.        assign this value to.
  3193.  
  3194.        Example:
  3195.  
  3196.        #include "cwlwin.h"
  3197.  
  3198.        FORMPTR form;
  3199.        FIELD_ENTRY field[] = {CWL_INTEGER,
  3200.                                 /* other initializations */ };
  3201.        int myvar;
  3202.  
  3203.          Page 50          The C Window Library                 Page 50
  3204.  
  3205.        main()
  3206.        {
  3207.          /* assume everything is initialized */
  3208.  
  3209.          /* get what was entered in field 1 and copy converted
  3210.             value to myvar */
  3211.          FormGetFieldData(form,1,&myvar);
  3212.        }
  3213.  
  3214.        Warning!  You must make sure that you assign the pointer to a
  3215.        variable of the correct type.  If not, you may overwrite memory
  3216.        when the conversion takes place.
  3217.  
  3218.        If there are no errors, FormGetFieldData() returns NO_ERROR.
  3219.  
  3220.        If there are errors, FormGetFieldData() returns one of the
  3221.        following and sets window_error_code to one these values:
  3222.  
  3223.        UNDEFINED_FORM if the FORMPTR does not exist.
  3224.  
  3225.        UNDEFINED_FIELD if the field entry does not exist
  3226.  
  3227.  
  3228.        Pre-filling a form with default data with
  3229.        FormInitializeFieldData()
  3230.        -----------------------------------------
  3231.  
  3232.        You can pre-fill a form with data before you start getting input
  3233.        from the form.  The only restriction is that the data must be in
  3234.        string form.
  3235.  
  3236.        The FormInitializeFieldData() partially or totally initializes a
  3237.        form with default data.  The data must be in string form.  Here
  3238.        is the prototype:
  3239.  
  3240.        int FormInitializeFieldData(FORMPTR form, char **data, int
  3241.                                    start, int end)
  3242.  
  3243.        The first argument is the pointer to a form.
  3244.  
  3245.        The second argument is a pointer to an array of characters.
  3246.        This will be dealt with in depth later on.
  3247.  
  3248.        The third and fourth arguments are the starting entry to
  3249.        initialize and the ending entry to initialize.
  3250.        FormInitializeFieldData() initializes a range of field entries.
  3251.        If the ending entry number is less than the starting entry
  3252.        number, the ending entry number will be made equal to the
  3253.        starting entry number.
  3254.  
  3255.  
  3256.        Setting up array of strings using Allocate2DArray() function
  3257.        ------------------------------------------------------------
  3258.  
  3259.        There are many ways to set up the array of strings required for
  3260.        the second argument to FormInitializeFieldData().  Here are
  3261.        various methods of assigning "123" to an array of strings:
  3262.  
  3263.          Page 51          The C Window Library                 Page 51
  3264.  
  3265.        /* Method 1 */
  3266.  
  3267.        #include <string.h>
  3268.        char data[5][4];
  3269.        FORMPTR form;
  3270.  
  3271.        main()
  3272.        {
  3273.          int i;
  3274.          /* ... assume form already initialized */
  3275.  
  3276.          /* copy "123" to data array */
  3277.          for (i=0;i<4;i++)
  3278.            strcpy(data[i],"123");
  3279.          FormInitializeFieldData(form,data,0,4);
  3280.        }
  3281.  
  3282.  
  3283.  
  3284.        /* Method 2 */
  3285.  
  3286.        #include <string.h>
  3287.        char *data[5] = {
  3288.                        "123",
  3289.                        "123",
  3290.                        "123",
  3291.                        "123",
  3292.                        "123" };
  3293.  
  3294.  
  3295.        main()
  3296.        {
  3297.  
  3298.          /* ... assume form already initialized */
  3299.          FormInitializeFieldData(form,data,0,4);
  3300.        }
  3301.  
  3302.  
  3303.  
  3304.        /* Method 3 */
  3305.  
  3306.        #include "cwlwin.h"
  3307.        char **data;
  3308.  
  3309.  
  3310.  
  3311.        main()
  3312.        {
  3313.          data = (char **)Allocate2DArray(5,4,sizeof(char));
  3314.          for (i=0;i<5;i++)
  3315.            strcpy(data[i],"123");
  3316.          FormInitializeFieldData(form,data,0,4);
  3317.        }
  3318.  
  3319.        The first two methods are self-explanatory, or if they are not,
  3320.        any elementary book on C programming will explain the methods
  3321.        used to initialize an array of strings.
  3322.  
  3323.          Page 52          The C Window Library                 Page 52
  3324.  
  3325.        The third method dynamically allocates memory for a two
  3326.        dimensional array.  Note the use of the function
  3327.        Allocate2DArray().  This function allocates a two dimensional
  3328.        array from the heap.  The first and second arguments to this
  3329.        function are the number of rows and columns in the array,
  3330.        respectively.  The third argument is the size of each data
  3331.        element (in bytes) in the array.  Since we want to initialize a
  3332.        two dimensional array of five strings with 4 characters for each
  3333.        string (you should allow an extra character for the terminating
  3334.        null for each string), the size of each element will be the size
  3335.        of one character.  Note the use of sizeof() to determine the
  3336.        size of a character.
  3337.  
  3338.        You can use Allocate2DArray() with any data type.  You must make
  3339.        sure that the return value is cast to the proper pointer type,
  3340.        since the returning data type is a void pointer (This rule is
  3341.        relaxed for C programs, but it is strictly enforced in C++
  3342.        programs).
  3343.  
  3344.        Allocate2DArray() returns a null pointer if it cannot allocate
  3345.        the memory desired.  You can allocate up to 64K of memory with
  3346.        this function.  To calculate the amount of memory that will be
  3347.        allocated, you should use the following formula:
  3348.  
  3349.                    rows X cols X sizeof(each data element)
  3350.  
  3351.        The prototype for this function is include in the window.h file.
  3352.        Since cwlwin.h includes window.h, there was no need to
  3353.        explicitly include window.h in any of the examples.
  3354.  
  3355.        Freeing a two dimensional array with Free2DArray()
  3356.        --------------------------------------------------
  3357.  
  3358.        If you want to dispose of a two dimensional array allocated with
  3359.        Allocate2DArray(), you should use the Free2DArray() function.
  3360.        The prototype is as follows:
  3361.  
  3362.                        void Free2DArray(void **array)
  3363.  
  3364.        The only argument is the pointer to the two dimensional array.
  3365.        Since this function does not return anything, you must make sure
  3366.        that you are actually freeing a valid two dimensional array.
  3367.  
  3368.  
  3369.        Using FormInitializeFieldData()
  3370.        -------------------------------
  3371.  
  3372.        As was stated above, FormInitializeFieldData() can totally or
  3373.        partially fill a form with default data.  The number of fields
  3374.        that will be filled is determined by the starting and ending
  3375.        field entry numbers, which are denoted by the third and fourth
  3376.        arguments to FormInitializeFieldData().  For instance if the
  3377.        starting entry is 0 and the ending entry is 5, the form manager
  3378.        will start filling in the fields 0 through 5 with the data
  3379.        stored in the array of strings, which was passed as the second
  3380.  
  3381.  
  3382.  
  3383.          Page 53          The C Window Library                 Page 53
  3384.  
  3385.        argument, to FormInitializeFieldData().  If a CWL_NULL is
  3386.        encountered in the array of strings before the last entry
  3387.        specified is reached,
  3388.  
  3389.        FormInitializeFieldData() will stop initializing fields and will
  3390.        return NO_ERROR.  FormInitializeFieldData() should be called before
  3391.        calling FormGetInput().
  3392.  
  3393.        #include "cwlwin.h"
  3394.        #define NORM  CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  3395.        #define REVERSE CREATE_VIDEO_ATTRIBUTE(WHITE,BLACK_)
  3396.  
  3397.        FIELD_ENTRY field_array[] =
  3398.        {CWL_INTEGER,0,35,"___",'_',1,3,FIELD_OVERRIDE_BACKWARD,0,
  3399.                 REVERSE,"3[0-9]",
  3400.        CWL_INTEGER,1,35,"___",'_',1,3,FIELD_OVERRIDE_BACKWARD,0,
  3401.                 REVERSE,"3[0-9]",
  3402.        CWL_STRING,2,35,"___",'_',1,3,FIELD_OVERRIDE_BACKWARD,0,
  3403.                 REVERSE,"3[0-9]",
  3404.        INTEGER,3,35,"___",'_',1,3,FIELD_OVERRIDE_BACKWARD,0,
  3405.                 REVERSE,"3[0-9]",
  3406.        CWL_UINTEGER,4,35,"___",'_',1,3,FIELD_OVERRIDE_BACKWARD,0,
  3407.                 REVERSE,"3[0-9]",
  3408.        CWL_CHAR,5,35,"_",'_',1,1,FIELD_OVERRIDE_BACKWARD,0,
  3409.                 REVERSE,"[YyNn]",
  3410.        CWL_CHAR,6,35,"_",'_',1,1,FIELD_OVERRIDE_BACKWARD,0,
  3411.                 REVERSE,"[YyNn]",
  3412.        CWL_INTEGER,7,35,"___",'_',1,3,FIELD_OVERRIDE_BACKWARD,0,
  3413.                 REVERSE,"3[0-9]",
  3414.        FIELDEND};
  3415.  
  3416.        WPOINTER w;
  3417.        FORMPTR form;
  3418.        char *data[8] = {
  3419.                        "123",
  3420.                        "0",
  3421.                        "ABC",
  3422.                        "200",
  3423.                        "230",
  3424.                        "N",
  3425.                        "Y",
  3426.                        "100"};
  3427.  
  3428.        main()
  3429.        {
  3430.          WindowInitializeSystem();
  3431.          FormInitializeSystem();
  3432.          WindowInitDesktop(0);
  3433.          w = WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,40,10,NORM,
  3434.                               NORM,SINGLEBOX);
  3435.          /* Initialize with WPOINTER */
  3436.          form = FormInitialize(w,  /* window to assign form to */
  3437.                                field_array, /* array of fields */
  3438.                                FORM_HIGHLIGHT); /* form options */
  3439.  
  3440.  
  3441.  
  3442.  
  3443.          Page 54          The C Window Library                 Page 54
  3444.  
  3445.          if (form == FORM_NULL_PTR)
  3446.          {
  3447.            printf("Form could not be initialized");
  3448.            exit(0);
  3449.          }
  3450.          FormInitializeFieldData(form,data,0,7);
  3451.          FormGetInput(form,1,0);   /* Get Input for the form */
  3452.        }
  3453.  
  3454.  
  3455.        If there are no errors, FormInitializeFieldData() returns
  3456.        NO_ERROR.
  3457.  
  3458.        If there are errors, FormInitializeFieldData() returns one of
  3459.        the following and sets window_error_code to one these values:
  3460.  
  3461.        UNDEFINED_FORM if the FORMPTR does not exist.
  3462.  
  3463.        UNDEFINED_FIELD if the starting field does not exist.
  3464.  
  3465.  
  3466.  
  3467.  
  3468.  
  3469.  
  3470.  
  3471.  
  3472.  
  3473.  
  3474.  
  3475.  
  3476.  
  3477.  
  3478.  
  3479.  
  3480.  
  3481.  
  3482.  
  3483.  
  3484.  
  3485.  
  3486.  
  3487.  
  3488.  
  3489.  
  3490.  
  3491.  
  3492.  
  3493.  
  3494.  
  3495.  
  3496.  
  3497.  
  3498.  
  3499.  
  3500.  
  3501.  
  3502.  
  3503.          Page 55          The C Window Library                 Page 55
  3504.  
  3505.                              SETTING FIELD OPTIONS
  3506.                              ---------------------
  3507.  
  3508.        In the previous sections, the field options were set up during
  3509.        initialization of the field entries.  You can also set field
  3510.        options at any time.  If you want to set field options during
  3511.        form input there are some restrictions.
  3512.  
  3513.  
  3514.        FormSetFieldOptions()
  3515.        ---------------------
  3516.  
  3517.        The FormSetFieldOptions() function turns on or off field
  3518.        options.  Here is the prototype:
  3519.  
  3520.        int FormSetFieldOptions(FORMPTR form, int entrynum, int options,
  3521.                                int flag)
  3522.  
  3523.        The first and second arguments are the form and the field entry
  3524.        number, respectively.
  3525.  
  3526.        The third arguments are the options desired.  The fourth
  3527.        arguments tell us whether to turn these options on or off.  If
  3528.        flag is equal to 1, the options are turned on.  If flag is 0,
  3529.        the options are turned off.
  3530.  
  3531.        The field options are the same options specified in the CREATING
  3532.        FIELD ENTRIES section above.  Multiple field options can be
  3533.        specified by using the bitwise OR (|) between field option
  3534.        constants, just as before.
  3535.  
  3536.        The field option that you would probably use this function for
  3537.        most of the time is the FIELD_PROTECT option.  As defined, if
  3538.        the FIELD_PROTECT option is on, the form manager will skip over
  3539.        this field and will go to the next available field.  You will
  3540.        probably want to toggle a field's FIELD_PROTECT option during
  3541.        input of a form.
  3542.  
  3543.        It is advised NOT to change the field options of a particular
  3544.        field if the field is currently being edited.  This may lead to
  3545.        undesired results.
  3546.  
  3547.        #include "cwlwin.h"
  3548.  
  3549.        FORMPTR form;
  3550.  
  3551.        /* ... skip other initializations ... */
  3552.  
  3553.        main()
  3554.        {
  3555.          /* ... skip initializations ... */
  3556.          /* set field protect option */
  3557.          FormSetFieldOptions(form,0,FIELD_PROTECT,1);
  3558.  
  3559.          /* turn off field protect option */
  3560.          FormSetFieldOptions(form,0,FIELD_PROTECT,0);
  3561.        }
  3562.  
  3563.          Page 56          The C Window Library                 Page 56
  3564.  
  3565.        If there are no errors, FormSetFieldOptions() returns NO_ERROR.
  3566.  
  3567.        If there are errors, FormSetFieldOptions() returns one of the
  3568.        following and sets window_error_code to one these values:
  3569.  
  3570.        UNDEFINED_FORM if the FORMPTR does not exist.
  3571.  
  3572.        UNDEFINED_FIELD if the field entry does not exist
  3573.  
  3574.  
  3575.  
  3576.  
  3577.  
  3578.  
  3579.  
  3580.  
  3581.  
  3582.  
  3583.  
  3584.  
  3585.  
  3586.  
  3587.  
  3588.  
  3589.  
  3590.  
  3591.  
  3592.  
  3593.  
  3594.  
  3595.  
  3596.  
  3597.  
  3598.  
  3599.  
  3600.  
  3601.  
  3602.  
  3603.  
  3604.  
  3605.  
  3606.  
  3607.  
  3608.  
  3609.  
  3610.  
  3611.  
  3612.  
  3613.  
  3614.  
  3615.  
  3616.  
  3617.  
  3618.  
  3619.  
  3620.  
  3621.  
  3622.  
  3623.          Page 57          The C Window Library                 Page 57
  3624.  
  3625.                              SETTING FORM OPTIONS
  3626.                              --------------------
  3627.  
  3628.        In the previous sections, the form options were set up when
  3629.        FormInitialize() was called.  You can also set form options at
  3630.        any time, including during input of a form.
  3631.  
  3632.  
  3633.        FormSetOptions()
  3634.        ----------------
  3635.  
  3636.        The FormSetOptions() function turns on or off form options.
  3637.        Here is the prototype:
  3638.  
  3639.             int FormSetOptions(FORMPTR form, int options, int flag)
  3640.  
  3641.        The first argument is the pointer to the form.
  3642.  
  3643.        The second argument are the options desired.  The third argument
  3644.        tells us whether to turn these options on or off.  If flag is
  3645.        equal to 1, the options are turned on.  If flag is 0, the
  3646.        options are turned off.
  3647.  
  3648.        The form options are the same options specified in the
  3649.        FormInitialize() function, which is described in the CREATING
  3650.        FIELD ENTRIES section above.  Multiple form options can be
  3651.        specified by using the bitwise OR (|) between form option
  3652.        constants, just as before.
  3653.  
  3654.        You should not use the FORM_VIRTUAL or FORM_HIGHLIGHT options in
  3655.        this function.  The FormInitialize() function uses these options
  3656.        to set up the form, and assumes the form will remain a virtual
  3657.        or windowed form throughout the life of the form.  The form
  3658.        manager also assumes that the FIELD_HIGHLIGHT option remains the
  3659.        same throughout the life of the form.
  3660.  
  3661.        #include "cwlwin.h"
  3662.  
  3663.        FORMPTR form;
  3664.  
  3665.        /* ... skip other initializations ... */
  3666.  
  3667.        main()
  3668.        {
  3669.  
  3670.          /* ... skip initializations ... */
  3671.  
  3672.          form = FormInitialize( /* arguments to FormInitialize */ );
  3673.  
  3674.          /* set form checking option */
  3675.          FormSetOptions(form,0,FORM_CHECK_ON,1);
  3676.  
  3677.          /* turn off form checking option */
  3678.          FormSetOptions(form,0,FORM_CHECK_OFF,0);
  3679.        }
  3680.  
  3681.  
  3682.  
  3683.          Page 58          The C Window Library                 Page 58
  3684.  
  3685.        If there are no errors, FormSetOptions() returns NO_ERROR.
  3686.  
  3687.        If there are errors, FormSetOptions() returns one of the
  3688.        following and sets window_error_code to one these values:
  3689.  
  3690.        UNDEFINED_FORM if the form does not exist.
  3691.  
  3692.        INVALID_FIELD_OPTION if FORM_VIRTUAL or FORM_HIGHLIGHT is used
  3693.        as an option.
  3694.  
  3695.  
  3696.  
  3697.  
  3698.  
  3699.  
  3700.  
  3701.  
  3702.  
  3703.  
  3704.  
  3705.  
  3706.  
  3707.  
  3708.  
  3709.  
  3710.  
  3711.  
  3712.  
  3713.  
  3714.  
  3715.  
  3716.  
  3717.  
  3718.  
  3719.  
  3720.  
  3721.  
  3722.  
  3723.  
  3724.  
  3725.  
  3726.  
  3727.  
  3728.  
  3729.  
  3730.  
  3731.  
  3732.  
  3733.  
  3734.  
  3735.  
  3736.  
  3737.  
  3738.  
  3739.  
  3740.  
  3741.  
  3742.  
  3743.          Page 59          The C Window Library                 Page 59
  3744.  
  3745.                       WRITING VALUES TO THE FIELD BUFFER
  3746.                       ----------------------------------
  3747.  
  3748.        You can write values to the field buffer as strings and have
  3749.        them displayed immediately.  This will be necessary if you want
  3750.        to change a field's value if the field is not the current field
  3751.        being edited.  The FormWriteFieldValue() function does just
  3752.        this.  This function is an alternative to the FormPutFieldData()
  3753.        function.
  3754.  
  3755.  
  3756.  
  3757.        FormWriteFieldValue()
  3758.        ---------------------
  3759.  
  3760.        The FormWriteFieldValue() writes a string to the field's input
  3761.        buffer and displays the changes immediately.  Here is the
  3762.        prototype:
  3763.  
  3764.        int FormWriteFieldValue(FORMPTR form, int entrynum, char *value)
  3765.  
  3766.        The first and second arguments are the form and the field entry
  3767.        number, respectively.
  3768.  
  3769.        The third argument is the pointer to the string of characters to
  3770.        write to the string buffer.  The length of the string cannot
  3771.        exceed the length of the field's input buffer.  If you do not
  3772.        know the length of the field buffer, you can use the
  3773.        FIELD_BUFSIZE() macro.
  3774.  
  3775.  
  3776.        #include "cwlwin.h"
  3777.  
  3778.        main()
  3779.        {
  3780.          /*... Assume initializations are done ... */
  3781.  
  3782.          FormWriteFieldValue(form,0,"45");
  3783.        }
  3784.  
  3785.        This writes a string "45" to the field's input buffer and
  3786.        displays "45" on the form (if the field's position is visible on
  3787.        the screen).
  3788.  
  3789.  
  3790.        If there are no errors, FormWriteFieldValue() returns NO_ERROR.
  3791.  
  3792.        If there are errors, FormWriteFieldValue() returns one of the
  3793.        following and sets window_error_code to one these values:
  3794.  
  3795.        UNDEFINED_FORM if the FORMPTR does not exist.
  3796.  
  3797.        UNDEFINED_FIELD if the field entry does not exist
  3798.  
  3799.  
  3800.  
  3801.  
  3802.  
  3803.          Page 60          The C Window Library                 Page 60
  3804.  
  3805.                           SETTING FIELD PRE-FUNCTIONS
  3806.                           ---------------------------
  3807.  
  3808.  
  3809.        The C Window Library's form manager allows functions to be
  3810.        called prior to inputting a field.  This function is not limited
  3811.        to just 'call a function and return to inputting' type of a
  3812.        function that you may find in some other commercial or shareware
  3813.        function libraries.  The pre functions in   The C Window Library
  3814.        have the added power of telling the form manager what to do next
  3815.        i.e. edit the current field, go to some other field, exit the
  3816.        form, etc.
  3817.  
  3818.        There are two ways of setting up a pre-input function.  One way
  3819.        is to define a global function that will be called for every
  3820.        field in every form defined.  The second way is to define a
  3821.        pre-input function for each individual field in a particular
  3822.        form.
  3823.  
  3824.  
  3825.        Defining a global pre-functions
  3826.        -------------------------------
  3827.  
  3828.        You can define a function that will be performed prior to
  3829.        inputting of every field in any form defined.  The
  3830.        CWLfield_prefunc function pointer points to this function.  Here
  3831.        is the prototype:
  3832.  
  3833.                int (*CWLfield_prefunc)(FORMPTR form, int *entrynum)
  3834.  
  3835.        The first argument is the pointer to the current active form.
  3836.  
  3837.        The second argument is a pointer to an integer that represents
  3838.        the current field number being edited.  The reason for a pointer
  3839.        and not the actual value will become apparent later on.
  3840.  
  3841.  
  3842.  
  3843.        Defining a field specific pre-input functions
  3844.        ---------------------------------------------
  3845.  
  3846.        The FormSetFieldPreFunction() defines a pre-input function for a
  3847.        particular field in a form.  Here is the prototype:
  3848.  
  3849.        int FormSetFieldPreFunction(FORMPTR form, int entrynum,
  3850.                                    int (*prefunc)(FORMPTR form, ]
  3851.                                    int *entry))
  3852.  
  3853.        The first argument is the pointer to the form, and the second
  3854.        the field number to assign the function to.
  3855.  
  3856.        The third argument is a pointer to the function that returns an
  3857.        integer.  The arguments to this function are the same as the
  3858.        CWLfield_prefunc function pointer defined above.
  3859.  
  3860.  
  3861.  
  3862.  
  3863.          Page 61          The C Window Library                 Page 61
  3864.  
  3865.        Return Values to the Form Manager
  3866.        ---------------------------------
  3867.  
  3868.        The CWLfield_prefunc and the function defined in the
  3869.        FormSetFieldPreFunction() MUST return a value back to the form
  3870.        manager.  This return value tells the form manager what to do
  3871.        next.  Here is a list of the valid return values:
  3872.  
  3873.        Option                         Definition
  3874.        ------                         ----------
  3875.  
  3876.        FIELD_PREVFIELD         Move input cursor to the previous field
  3877.                                in the form and start editing from
  3878.                                there.
  3879.  
  3880.        FIELD_NEXTFIELD         Move input cursor to the next field in
  3881.                                the form and continue editing the next
  3882.                                field.
  3883.  
  3884.        FIELD_CONTINUE_PROCESS  Edit the input for the current field.
  3885.  
  3886.        FIELD_PROCESS_DATA      Process input that was already entered
  3887.                                in the field.
  3888.  
  3889.        FORM_CLEAR              Clear the form and move input cursor to
  3890.                                first available field.
  3891.  
  3892.        FORM_ACCEPT             Accept the current input in the form and
  3893.                                exit.
  3894.  
  3895.        FIELD_NEWFIELD          Move cursor to a new field and continue
  3896.                                editing from there.
  3897.  
  3898.        FORM_CANCEL             Do not accept any input that may have
  3899.                                been previously entered and quit
  3900.  
  3901.        The FIELD_PREVFIELD return value will move the input cursor to
  3902.                                 the previous field in the form.  If you
  3903.        try to move beyond the first available field on the form the
  3904.        FORM_WRAP and/or the FORM_EXIT_INITIAL form options will take
  3905.        action depending on whether they are on or off.  See CREATING
  3906.        FIELD ENTRIES for a definition of the FORM_WRAP and
  3907.        FORM_EXIT_INITIAL options.
  3908.  
  3909.        The FIELD_NEXTFIELD return value will move the input cursor to
  3910.        the next field in the form.  If you try to move beyond the first
  3911.        available field in the form, the FORM_WRAP form option will take
  3912.        action depending on whether this option was turned on.
  3913.  
  3914.        The FIELD_CONTINUE_PROCESS return value will just let the form
  3915.        manager edit the current field, just as if the pre-input
  3916.        function was not called.
  3917.  
  3918.        The FIELD_PROCESS_DATA return value will process whatever data
  3919.        is residing the field's input buffer, and will not edit the
  3920.        current field.  You can place strings in the field input buffer
  3921.        by calling the FormWriteFieldValue() function.  The
  3922.  
  3923.          Page 62          The C Window Library                 Page 62
  3924.  
  3925.        FIELD_PROCESS_DATA will still right or left justify, comma
  3926.        format, etc. whatever is in the field buffer, just as if it were
  3927.        entered manually (edited).
  3928.  
  3929.        The FORM_CLEAR return value clears the form of all input data
  3930.        and moves the input cursor to the first available field.
  3931.  
  3932.        The FORM_ACCEPT return value accepts all the input from the
  3933.        input fields and exits.  The form is not exited automatically if
  3934.        the FORM_CHECK option is on or if a field in the form has the
  3935.        FIELD_CHECK option on.  See CREATING FIELD ENTRIES for a
  3936.        definition of the FORM_CHECK and FIELD_CHECK options.
  3937.  
  3938.        The FIELD_NEWFIELD return value moves the input cursor to the
  3939.        field assigned to the pointer to the current entry.  If you
  3940.        remember, the pre-function prototype passed a pointer to the
  3941.        current field number.  If you assign a field number to the
  3942.        dereferenced pointer and the FIELD_NEWFIELD return value is
  3943.        used, the form manager will move the input cursor to the field
  3944.        desired.  If the field entry does not exist, the form manager
  3945.        will not move the input cursor.  If the field is protected
  3946.        (FIELD_PROTECT flag is on) for the desired field, the input
  3947.        cursor is not moved.
  3948.  
  3949.        The FORM_CANCEL rejects all input and exits the form.  The form
  3950.        is not automatically exited if there is an exit function defined
  3951.        for the form.  Form exit functions are discussed later in the
  3952.        manual.
  3953.  
  3954.        If both the CWLfield_prefunc and an entry has a pre-input
  3955.        function defined via the FormSetFieldPreFunction() function, the
  3956.        CWLfield_prefunc is performed first.  If the return value from
  3957.        the global function is FIELD_CONTINUE_PROCESS, then the
  3958.        pre-input function defined for the field is performed.
  3959.  
  3960.        #include "cwlwin.h"
  3961.        #include "menu.h"
  3962.  
  3963.        #define NORM  CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  3964.        #define REVERSE CREATE_VIDEO_ATTRIBUTE(WHITE_,BLACK_)
  3965.        #define NUMPROMPTS 5
  3966.  
  3967.        FIELD_ENTRY field_array[] =
  3968.        {CWL_INTEGER,0,35,"___",'_',1,3,FIELD_RJUSTIFY01,REVERSE,"3[0-9]",
  3969.         CWL_STRING, 1, 35, "__________", '_', 0, 10, NO_FIELD_OPTIONS,
  3970.                 0,REVERSE, "10.",
  3971.         CWL_LINTEGER,2, 35, "_________", '_', 2, 12,
  3972.                 FIELD_COMMA|FIELD_ZSUPPRESS2, 0,REVERSE, "9[0-9]",
  3973.         CWL_DOUBLE,3, 20, "_______",'_',1,7, FIELD_COMMA|FIELD_LJUSTIFY,0,
  3974.                 REVERSE,"7[0-9/.]",
  3975.         CWL_CHAR, 4, 20, "_", '_', 1, 1, FIELD_UPPERCASE, 0,REVERSE,
  3976.                 "[YyNn]",
  3977.        FIELDEND};
  3978.  
  3979.        FORMPTR form;
  3980.        WPOINTER w, helpwin;
  3981.  
  3982.  
  3983.          Page 63          The C Window Library                 Page 63
  3984.  
  3985.        char *prompt[] = { "Enter an integer:",
  3986.                           "Choose a string:",
  3987.                           "Enter a large integer value:",
  3988.                           "Enter a double:",
  3989.                           "Enter Yes or No (Y/N):"};
  3990.  
  3991.        char *help[] =   {"Enter a value between 0 and 999",
  3992.                        "Use Up arrow or down arrow to make selection",
  3993.                        "Enter a value between 0 and 2,000,000",
  3994.                        "Enter a value with a decimal point",
  3995.                        "Enter a 'Y' for yes, 'N' for no"};
  3996.  
  3997.        int display_help();
  3998.        int get_choice();
  3999.        int choose_list();
  4000.  
  4001.        POPUP_MENU_ENTRY popup_entry[] = {"Choice 1",0,0,0,NULLFN,
  4002.                                        "Choice 2",1,0,0,NULLFN,
  4003.                                        "Choice 3",2,0,0,NULLFN,
  4004.                                        "Choice 4",3,0,0,NULLFN,
  4005.                                        "Choice 5",4,0,0,NULLFN,
  4006.                                        "Choice 6",5,0,0,NULLFN,
  4007.                                        "Choice 7",6,0,0,NULLFN,
  4008.                                        CWL_NULL,-1};
  4009.        POPUP_MENU_PTR popup;
  4010.        unsigned menu_colors[NUMPOPUPCOLORS];
  4011.        main()
  4012.        {
  4013.          int i;
  4014.          WindowInitializeSystem();
  4015.          FormInitializeSystem();
  4016.          FormInitializeFloat();
  4017.          WindowInitDesktop(0);
  4018.  
  4019.          menu_colors[ENTRYCOLOR] = CREATE_VIDEO_ATTRIBUTE(white,black);
  4020.          menu_colors[BORDERCOLOR] =CREATE_VIDEO_ATTRIBUTE(white,black);
  4021.          menu_colors[HOTKEYCOLOR] = CREATE_VIDEO_ATTRIBUTE(white,blue);
  4022.          menu_colors[HIGHLIGHTCOLOR] =
  4023.                         CREATE_VIDEO_ATTRIBUTE(cyan,black);
  4024.          menu_colors[UNAVAILCOLOR] =
  4025.                         CREATE_VIDEO_ATTRIBUTE(white,black);
  4026.  
  4027.          w = WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,78,22,NORM,
  4028.                               NORM,SINGLEBOX);
  4029.  
  4030.          /* write prompts to the form window */
  4031.          for (i=0;i<NUMPROMPTS;i++)
  4032.            WindowWriteString(w,prompt[i],i,0);
  4033.  
  4034.          /* setup help window */
  4035.          helpwin = WindowInitialize(DESKTOP_WINDOW,NOBORDER,24,0,78,1,
  4036.                                     REVERSE,REVERSE,0);
  4037.          popup = PopupCreateMenu(popup_entry,menu_colors,3,9,7,
  4038.                                  NO_POPUP_OPTIONS,WNULLFN,VWNULLFN);
  4039.  
  4040.  
  4041.  
  4042.  
  4043.          Page 64          The C Window Library                 Page 64
  4044.  
  4045.          /* initialize form */
  4046.          form = FormInitialize(w,field_array,FORM_HIGHLIGHT);
  4047.  
  4048.          FormSetListField(form,1,popup);
  4049.  
  4050.          /* set field pre-func of second field */
  4051.          FormSetFieldPreFunction(form,1,get_choice);
  4052.  
  4053.          /* display help window */
  4054.          WindowDisplay(helpwin, 2, NOEFFECT);
  4055.  
  4056.          /* get form info */
  4057.          FormGetInput(form,1,0);
  4058.        }
  4059.  
  4060.        /* Displays help for each field */
  4061.        int display_help(FORMPTR form, int *entry)
  4062.        {
  4063.          /* clear window and display appropriate help */
  4064.          WindowClear(helpwin);
  4065.          WindowWriteString(helpwin,help[*entry],0,0);
  4066.  
  4067.          /* return value back to form manager */
  4068.          return FIELD_CONTINUE_PROCESS;
  4069.        }
  4070.  
  4071.  
  4072.        The above example displays a help message for each input field.
  4073.        Note that the display_help() function returns a
  4074.        FIELD_CONTINUE_PROCESS to the form manager.
  4075.  
  4076.        If there are no errors, FormSetFieldPreFunction() returns
  4077.        NO_ERROR.
  4078.  
  4079.        If there are errors, FormSetFieldPreFunction() returns one of
  4080.        the following and sets window_error_code to one these values:
  4081.  
  4082.        UNDEFINED_FORM if the FORMPTR does not exist.
  4083.  
  4084.        UNDEFINED_FIELD if the field entry does not exist
  4085.  
  4086.  
  4087.  
  4088.  
  4089.  
  4090.  
  4091.  
  4092.  
  4093.  
  4094.  
  4095.  
  4096.  
  4097.  
  4098.  
  4099.  
  4100.  
  4101.  
  4102.  
  4103.          Page 65          The C Window Library                 Page 65
  4104.  
  4105.                          SETTING FIELD POST FUNCTIONS
  4106.                          ----------------------------
  4107.  
  4108.  
  4109.        The C Window Library's form manager allows functions to be
  4110.        called after inputting a field.
  4111.  
  4112.        There are two ways of setting up a post-input function.  One way
  4113.        is to define a global function that will be called for every
  4114.        field in every form defined.  The second way is to define a
  4115.        post-input function for each individual field in a particular
  4116.        the form.
  4117.  
  4118.  
  4119.        Defining a global post-function
  4120.        -------------------------------
  4121.  
  4122.        You can define a function that will be performed prior to
  4123.        inputting of every field in any form defined.  The
  4124.        CWLfield_postfunc function pointer points to this function.
  4125.        Here is the prototype:
  4126.  
  4127.                int (*CWLfield_postfunc)(FORMPTR form, int *entrynum)
  4128.  
  4129.        The first argument is the pointer to the current active form.
  4130.  
  4131.        The second argument is a pointer to an integer that represents
  4132.        the current field number being edited.  The reason for a pointer
  4133.        and not the actual value will become apparent later on.
  4134.  
  4135.  
  4136.        Defining a field specific post-function
  4137.        ---------------------------------------
  4138.  
  4139.        The FormSetFieldPostFunction() defines a post-input function for
  4140.        a particular field in a form.  Here is the prototype:
  4141.  
  4142.        int FormSetFieldPostFunction(FORMPTR form, int entrynum,
  4143.                           int (*postfunc)(FORMPTR form, int *entry))
  4144.  
  4145.        The first argument is the pointer to the form, and the second
  4146.        the field number to assign the function to.
  4147.  
  4148.        The third argument is a pointer to the function that returns an
  4149.        integer.  The arguments to this function are the same as the
  4150.        CWLfield_postfunc function pointer defined above.
  4151.  
  4152.  
  4153.        Return Values to the Form Manager
  4154.        ---------------------------------
  4155.  
  4156.        The CWLfield_postfunc and the function defined in the
  4157.        FormSetFieldPostFunction() MUST return a value back to the form
  4158.        manager.  This return value tells the form manager what to do
  4159.        next.  Here is a list of the valid return values:
  4160.  
  4161.  
  4162.  
  4163.          Page 66          The C Window Library                 Page 66
  4164.  
  4165.        Option                            Definition
  4166.        ------                            ----------
  4167.  
  4168.        FIELD_PREVFIELD            Move input cursor to the previous
  4169.                                   field in the form and start editing
  4170.                                   from there.
  4171.  
  4172.        FIELD_NEXTFIELD            Move input cursor to the next field
  4173.                                   in the form and continue editing the
  4174.                                   next field.
  4175.  
  4176.        FIELD_CONTINUE_PROCESS     Continue processing the field
  4177.                                   (display value entered in field
  4178.                                   buffer from previous edit).
  4179.  
  4180.        FIELD_PROCESS_DATA         Same as FIELD_CONTINUE_PROCESS.
  4181.  
  4182.        FORM_CLEAR                 Clear the form and move input cursor
  4183.                                   to first available field.
  4184.  
  4185.        FORM_ACCEPT                Accept the current input in the form
  4186.                                   and exit.
  4187.  
  4188.        FIELD_NEWFIELD             Move cursor to a new field and
  4189.                                   continue editing from there.
  4190.  
  4191.        FORM_CANCEL                Do not accept any input that may have
  4192.                                   been previously entered and quit
  4193.  
  4194.        The above return values are the same as the return values for
  4195.        pre-input function except for the FIELD_CONTINUE_PROCESS and
  4196.        FIELD_PROCESS_DATA functions.  FIELD_CONTINUE_PROCESS just
  4197.        continues as if no post-input function was called.
  4198.        FIELD_PROCESS_DATA has the same definition as
  4199.        FIELD_CONTINUE_PROCESS.
  4200.  
  4201.        If both the CWLfield_postfunc and an entry has a post-input
  4202.        function defined via the FormSetFieldPostFunction() function,
  4203.        the CWLfield_postfunc is performed first.  If the return value
  4204.        from the global function is FIELD_CONTINUE_PROCESS, then the
  4205.        post-input function defined for the field is performed.
  4206.  
  4207.        Here is an example of using the post-input functions:
  4208.  
  4209.        #include <stdio.h>
  4210.        #include "cwlwin.h"
  4211.        #define NORM  CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  4212.        #define REVERSE CREATE_VIDEO_ATTRIBUTE(WHITE_,BLACK_)
  4213.        #define NUMPROMPTS 3
  4214.  
  4215.        FIELD_ENTRY field_array[] =
  4216.        {CWL_INTEGER,0,35,"___",'_',1,3,FIELD_RJUSTIFY,0,REVERSE,"3[0-9]",
  4217.        CWL_INTEGER,1,35,"___",'_',1,3,FIELD_RJUSTIFY,0,REVERSE,"3[0-9]",
  4218.        CWL_INTEGER,2,35,"___",'_',1,3,FIELD_RJUSTIFY,0,REVERSE,"3[0-9]",
  4219.        CWL_INTEGER,3,35,"___",'_',1,3,FIELD_RJUSTIFY,0,REVERSE,"3[0-9]",
  4220.        CWL_INTEGER,4,35,"____",'_',1,4,FIELD_RJUSTIFY|FIELD_PROTECT,0,
  4221.                          REVERSE,"4[0-9]",
  4222.        FIELDEND};
  4223.  
  4224.          Page 67          The C Window Library                 Page 67
  4225.  
  4226.        FORMPTR form;
  4227.        WPOINTER w, helpwin;
  4228.  
  4229.        char *prompt = "Enter a number between 0 and 999:";
  4230.        char *totstr = "Current Total :";
  4231.        int display_total();
  4232.        main()
  4233.        {
  4234.          int i;
  4235.          WindowInitializeSystem();
  4236.          FormInitializeSystem();
  4237.          WindowInitDesktop(0);
  4238.          w = WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,78,22,NORM,
  4239.                               NORM,SINGLEBOX);
  4240.  
  4241.          /* write prompts to the form window */
  4242.          for (i=0;i<=NUMPROMPTS;i++)
  4243.          WindowWriteString(w,prompt,i,0);
  4244.          WindowWriteString(w,totstr,4,0);
  4245.  
  4246.          /* initialize form */
  4247.          form = FormInitialize(w,field_array,FORM_HIGHLIGHT);
  4248.  
  4249.          /* set global post-function */
  4250.          CWLfield_postfunc = display_total;
  4251.  
  4252.          /* get form info */
  4253.          FormGetInput(form,1,0);
  4254.        }
  4255.  
  4256.        /* call total function */
  4257.        int display_total(FORMPTR form, int *entry)
  4258.        {
  4259.          int i,total=0,num;
  4260.          for (i=0;i<4;i++)
  4261.          {
  4262.            FormGetFieldData(form,i,&num);
  4263.            total+=num;
  4264.          }
  4265.          FormPutFieldData(form,4,total);
  4266.          return FIELD_CONTINUE_PROCESS;
  4267.        }
  4268.  
  4269.        The above example displays a running total of four input fields.
  4270.        The total is displayed in the fifth input field.  Note the return
  4271.        value of FIELD_CONTINUE_PROCESS, which informs the form manager to
  4272.        carry on as if no post-input function had been call.
  4273.  
  4274.        If there are no errors, FormSetFieldPostFunction() returns
  4275.        NO_ERROR.
  4276.  
  4277.        If there are errors, FormSetFieldPostFunction() returns one of the
  4278.        following and sets window_error_code to one these values:
  4279.  
  4280.        UNDEFINED_FORM if the FORMPTR does not exist.
  4281.  
  4282.        UNDEFINED_FIELD if the field entry does not exist.
  4283.  
  4284.          Page 68          The C Window Library                 Page 68
  4285.  
  4286.                      UNDEFINED KEYSTROKE PROCESSING
  4287.                      ------------------------------
  4288.  
  4289.        Another powerful feature of the form library is that you can
  4290.        call a function for keys that are not in the current key
  4291.        definitions.  For instance, say you want the Tab key and the
  4292.        down arrow to mean accept the input and go to the next field.
  4293.        Since there is only room for one definition for accept input,
  4294.        you can write a function that checks for the Tab key, and return
  4295.        a value to the form manager as to what action to take.
  4296.  
  4297.  
  4298.        The CWLform_undef_fkey_func and CWLform_undef_akey_func function
  4299.        pointers
  4300.        --------
  4301.  
  4302.        There are two global variables, CWLform_undef_fkey_func and
  4303.        CWLform_undef_akey_func.  These two variables are pointers to
  4304.        functions that return an integer.  By setting these functions to
  4305.        point to your own functions, you can process undefined
  4306.        keystrokes yourself and return to the form manager what action
  4307.        to take.
  4308.  
  4309.        The CWLform_undef_fkey_func is used to define keys that are not
  4310.        normal ASCII keys.  For instance, Control key and Alt key
  4311.        combinations, the F-keys, PgDn and PgUp, etc.  The
  4312.        CWLform_undef_akey_func is used to define normal ASCII keys
  4313.        (keys with ASCII values between 32 and 255, inclusive).
  4314.  
  4315.        Whenever an undefined key is encountered, the form manager will
  4316.        pass the current FORMPTR, current field entry (as an integer),
  4317.        the string that has been currently entered, the current key
  4318.        pressed, and the current position number of the character being
  4319.        processed to your function.  The prototype for this function is
  4320.        as follows:
  4321.  
  4322.        int (*CWLform_undef_fkey_func)(FORMPTR form, /* current form */
  4323.                                int entry,     /* current field */
  4324.                                char *str,/* string currently entered */
  4325.                                int key,  /* key that was pressed */
  4326.                                int *pos) /* position number of current
  4327.                                character being processed */
  4328.  
  4329.        The prototype to the CWLform_undef_akey_func is similar to the
  4330.        one above.  The str is a pointer to a null-terminated string of
  4331.        characters that has been currently entered.  For instance, if
  4332.        the string currently entered is
  4333.  
  4334.                ABC123
  4335.  
  4336.        str will point to "ABC123".  The key value is the key that was
  4337.        pressed.  You should use the values defined in the header file
  4338.        "keycodes.h" if you want to check for non-ascii keys.  This will
  4339.        ensure that you are properly checking the keystroke desired.
  4340.        For instance, if you want to check if the key pressed was the
  4341.        Page Up key, use the constant PGUP defined in keycodes.h.
  4342.  
  4343.  
  4344.          Page 69          The C Window Library                 Page 69
  4345.  
  4346.        The pos argument is a pointer to an integer that denotes the
  4347.        number of the current character that the cursor is on.  The
  4348.        first character is at position number 0, the second character in
  4349.        the input field is 1, etc.  If there is an input mask the
  4350.        position number does not include any characters that are used to
  4351.        create the non-input positions.  For instance:
  4352.  
  4353.                        "__/__/__ "
  4354.                         01 23 45
  4355.        The numbers under the mask are the position numbers for each
  4356.        character.  The reason why the pos argument is a pointer, and
  4357.        not a regular integer will be defined later.
  4358.  
  4359.  
  4360.        Specifying when to call an undefined key function in a Regular
  4361.        Expression
  4362.        ----------
  4363.  
  4364.        An empty bracketed simple regular expression tells the form
  4365.        manager to call the undefined keystroke function.  An example of
  4366.        this type of regular expression is as follows:
  4367.  
  4368.                Regular           Definition
  4369.                Expression        ----------
  4370.                ----------
  4371.  
  4372.               [A-Z][]           The first input position must be
  4373.                                 between 'A' and 'Z', and the second
  4374.                                 position will automatically call
  4375.                                 the user defined undefined
  4376.                                 keystroke function.
  4377.  
  4378.               20[]              All twenty input positions will
  4379.                                 call the undefined keystroke
  4380.                                 function.
  4381.  
  4382.               3[0-9]2[]2[A-Z]   The first three input positions
  4383.                                 must be between '0' and '9', the
  4384.                                 next two input positions
  4385.                                 automatically call the undefined
  4386.                                 keystroke function, and the last two
  4387.                                 positions must be between 'A' and 'Z'.
  4388.  
  4389.  
  4390.        If you use this form of a regular expression, you MUST have
  4391.        defined an undefined keystroke function.  If you did not define
  4392.        one, you will more than likely get into an infinite loop.  Using
  4393.        this form of regular expression combined with the return values
  4394.        (defined below) that can be returned to the input manager, you
  4395.        will virtually have total control of the way the input is
  4396.        handled.
  4397.  
  4398.  
  4399.        Return Values To The Form Manager
  4400.        ---------------------------------
  4401.        When writing your function you must return an integer to the
  4402.        form manager.  This integer will inform the form manager as to
  4403.  
  4404.          Page 70          The C Window Library                 Page 70
  4405.  
  4406.        what action to take.  Here are a list of the return values and
  4407.        what they inform the form manager:
  4408.  
  4409.        Return                         Action to
  4410.        Value                            Take
  4411.        ------                         ---------
  4412.  
  4413.        FIELD_CONTINUE          Do not Process keystroke and continue
  4414.                                getting input.
  4415.  
  4416.        FIELD_MOVELEFT          Move cursor left in field.
  4417.  
  4418.        FIELD_MOVERIGHT         Move cursor right in field.
  4419.  
  4420.        FIELD_DELNOMOVE         Delete character at cursor.
  4421.  
  4422.        FIELD_INSTOGGLE         Toggle Insert/Overwrite mode.
  4423.  
  4424.        FIELD_BACKSPACE         Destructive Backspace.
  4425.  
  4426.        FIELD_ACCEPT            Accept Input and go to next field.
  4427.  
  4428.        FIELD_ACCEPTDEFAULT     Accept default field string and return.
  4429.  
  4430.        FIELD_ERASEINPUT        Erase Input and go to first character in
  4431.                                the field.
  4432.  
  4433.        FIELD_GOTOFIRST         Go to first input character in field.
  4434.  
  4435.        FIELD_GOTOLAST          Move cursor to last input character in
  4436.                                field.
  4437.  
  4438.        FIELD_INSERTCHAR        Accept character as valid and insert it
  4439.                                at the current cursor position.
  4440.  
  4441.        FIELD_NEXTFIELD         Accept input and go to the next field in
  4442.                                the form.
  4443.  
  4444.        FIELD_PREVFIELD         Accept input and go to the previous
  4445.                                field.
  4446.  
  4447.        FORM_ACCEPT             Accept all input in the form and exit
  4448.                                form.
  4449.  
  4450.        FORM_CLEAR              Clear the form and move input to first
  4451.                                available field entry.
  4452.  
  4453.        FORM_CANCEL             Do not accept any input that may have
  4454.                                been previously entered and quit
  4455.                                 editing.
  4456.  
  4457.        FIELD_MOVE_TO_CHARACTER   Move cursor to input position
  4458.                                  specified in the *pos argument.
  4459.  
  4460.        The FIELD_MOVE_TO_CHARACTER return value moves the input cursor
  4461.        to the position in the input string specified in the fourth
  4462.  
  4463.  
  4464.          Page 71          The C Window Library                 Page 71
  4465.  
  4466.        argument of CWLform_undef_akey_func or CWLform_undef_fkey_func.
  4467.        If you recall, the fourth argument was a pointer to an integer.
  4468.        You can assign a value to the *pos argument in your user defined
  4469.        function, and then return a FIELD_MOVE_TO_CHARACTER return code
  4470.        to move the input cursor to the desired input position.
  4471.  
  4472.        These user-defined functions can do anything, not just process
  4473.        keystrokes.  For instance, if you want F1 to be a help key,
  4474.        where the help function is in a function called do_help() you
  4475.        must make sure that:
  4476.  
  4477.  
  4478.        a) the F1 key is undefined (not defined in the CWLform_edit_key
  4479.           array)
  4480.  
  4481.        b) the CWLform_undef_fkey_func function pointer points to your
  4482.           function c) return an integer to the form manager from your
  4483.           function.
  4484.  
  4485.        Here is a typical way that this would be set up:
  4486.  
  4487.  
  4488.        #include "window.h"
  4489.  
  4490.        /*  ... Other #includes and #defines */
  4491.  
  4492.        int do_help();           /* define help function */
  4493.  
  4494.        main()
  4495.        {
  4496.          WindowInitializeSystem();
  4497.          FormInitializeSystem();
  4498.          /* ...Some code */
  4499.          CWLform_undef_fkey_func = do_help;   /* point function pointer
  4500.                                               to do_help */
  4501.          FormGetInput(/*  ... Parameters */);    /* call input
  4502.                                                     function */
  4503.  
  4504.          /* ... Other code */
  4505.        }
  4506.  
  4507.  
  4508.        int do_help(FORMPTR form, int entry, char *str, int ch, int pos)
  4509.        {
  4510.          if (ch == F1)                     /* check for F1 */
  4511.          {
  4512.                /* help function goes here */
  4513.  
  4514.          }
  4515.          return FIELD_DONT_PROCESS;  /* make sure form manager does not
  4516.                                    process this or any other undefined
  4517.                                    keystroke */
  4518.        }
  4519.  
  4520.        With this flexibility in the input functions, you can totally
  4521.        control how input is handled.
  4522.  
  4523.  
  4524.          Page 72          The C Window Library                 Page 72
  4525.  
  4526.                         PROCESSING EDITING ERRORS
  4527.                         -------------------------
  4528.  
  4529.        There are two categories of errors that The C Window Library
  4530.        checks for when editing a field in a form.  The first category
  4531.        includes checking to see if enough characters have been entered
  4532.        into the field and to make sure the input matches the regular
  4533.        expression.
  4534.  
  4535.        The second category are errors that occur when the field is
  4536.        checked to see if the data entered falls in a valid range, the
  4537.        name entered is found in a database of some type, etc. namely
  4538.        the errors that The C Window Library cannot check for
  4539.        internally, only you (the programmer) knows whether the data
  4540.        entered is valid.
  4541.  
  4542.        This section deals with the first category of errors.
  4543.  
  4544.        Minimum Number of Characters Error Checking
  4545.        -------------------------------------------
  4546.  
  4547.        The C Window Library internally checks to see if the number of
  4548.        characters entered manually into a field (not data written to
  4549.        the field using the FormWriteFieldValue() function) is enough to
  4550.        satisfy the minimum number of characters that must be entered
  4551.        for the field.  As stated before, the minimum number of
  4552.        characters expected is initialized in the FIELD_ENTRY structure.
  4553.  
  4554.  
  4555.        Overriding Error Checking for Minimum number of characters
  4556.        ----------------------------------------------------------
  4557.  
  4558.        You can override checking the number of characters entered by
  4559.        turning on one or both of the override options,
  4560.        FIELD_OVERRIDE_FORWARD and FIELD_OVERRIDE_BACKWARD.  The
  4561.        FIELD_OVERRIDE_FORWARD overrides checking when the field is
  4562.        exited with a forward (toward the last field in the form)
  4563.        advance.  The FIELD_OVERRIDE_BACKWARD overrides checking when
  4564.        the field is exited with a backward advance (toward the first
  4565.        field in the form).  As stated in previous sections,
  4566.        FormSetFieldOptions() turns on or turns off field options.  Some
  4567.        useful purposes of overriding the number of characters entered
  4568.        error checking is to allow the user to move to a previous field
  4569.        so that it can be changed, without having to enter some data in
  4570.        the current field.  Here is an example of using this technique
  4571.        with the FIELD_OVERRIDE_BACKWARD option.
  4572.  
  4573.  
  4574.        #include "cwlwin.h"
  4575.  
  4576.        #define NORM  CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  4577.        #define REVERSE CREATE_VIDEO_ATTRIBUTE(WHITE_,BLACK_)
  4578.        #define NUMPROMPTS 8
  4579.  
  4580.  
  4581.  
  4582.  
  4583.  
  4584.          Page 73          The C Window Library                 Page 73
  4585.  
  4586.        FIELD_ENTRY field_array[] =
  4587.        {CWL_INTEGER,0,35,"___",'_',1,3,FIELD_OVERRIDE_BACKWARD,0,REVERSE,
  4588.                "3[0-9]",
  4589.         CWL_INTEGER,1,35,"___",'_',1,3,FIELD_OVERRIDE_BACKWARD,0,REVERSE,
  4590.                "3[0-9]",
  4591.        CWL_INTEGER,2,35,"___",'_',1,3,FIELD_OVERRIDE_BACKWARD,0,REVERSE,
  4592.                "3[0-9]",
  4593.        CWL_INTEGER,3,35,"___",'_',1,3,FIELD_OVERRIDE_BACKWARD,0,REVERSE,
  4594.                "3[0-9]",
  4595.        CWL_INTEGER,4,35,"___",'_',1,3,FIELD_OVERRIDE_BACKWARD,0,REVERSE,
  4596.                "3[0-9]",
  4597.        CWL_INTEGER,5,35,"___",'_',1,3,FIELD_OVERRIDE_BACKWARD,0,REVERSE,
  4598.                "3[0-9]",
  4599.        CWL_INTEGER,6,35,"___",'_',1,3,FIELD_OVERRIDE_BACKWARD,0,REVERSE,
  4600.                "3[0-9]",
  4601.        CWL_INTEGER,7,35,"___",'_',1,3,FIELD_OVERRIDE_BACKWARD,0,REVERSE,
  4602.                "3[0-9]",
  4603.        FIELDEND};
  4604.  
  4605.        FORMPTR form;
  4606.        WPOINTER w;
  4607.  
  4608.        char *prompt = "Enter a number :";
  4609.  
  4610.        main()
  4611.        {
  4612.          int i;
  4613.          WindowInitializeSystem();
  4614.          FormInitializeSystem();
  4615.          WindowInitDesktop(0);
  4616.  
  4617.          w = WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,78,22,NORM,
  4618.                               NORM,SINGLEBOX);
  4619.  
  4620.          /* write prompts to the form window */
  4621.          for (i=0;i<NUMPROMPTS;i++)
  4622.            WindowWriteString(w,prompt,i,0);
  4623.  
  4624.          /* initialize form */
  4625.          form = FormInitialize(w,field_array,FORM_HIGHLIGHT);
  4626.  
  4627.          /* get form info */
  4628.          FormGetInput(form,1,0);
  4629.        }
  4630.  
  4631.        The example above allows the user to edit a previous field even
  4632.        though the field may not contain any characters.  The
  4633.        FIELD_OVERRIDE_BACKWARD option allows us to override the minimum
  4634.        number of characters error check.
  4635.  
  4636.  
  4637.        Checking if Field Characters Match Regular Expression
  4638.        -----------------------------------------------------
  4639.  
  4640.        Another check that is done internally is to see if each
  4641.        character entered matches the corresponding regular expression
  4642.        character.
  4643.  
  4644.          Page 74          The C Window Library                 Page 74
  4645.  
  4646.        This check is only done automatically if the FIELD_CHECKREGEXP
  4647.        or FIELD_CHECKREGEXP_IGNORECASE options are turned on.  The way
  4648.        these two options work are exactly the same as the CHECKREGEXP
  4649.        and CHECKREGEXP_IGNORECASE options work for single input fields
  4650.        in the WindowGet...() family of functions.  See page 6 for more
  4651.        details on these options.
  4652.  
  4653.  
  4654.        Calling a User Written Function when errors occur
  4655.        -------------------------------------------------
  4656.  
  4657.        You can set up a function that will be called if any of the
  4658.        fields fail the minimum number of entered characters test or the
  4659.        regular expression error test by pointing the CWLedit_error_func
  4660.        function pointer to a user-written function.  Here is the
  4661.        prototype to this function pointer:
  4662.  
  4663.        int (*CWLedit_error_func)(FORMPTR form, int entrynum,
  4664.                                     int errtype, char *str, int errval)
  4665.  
  4666.        The first argument is a pointer to the form of where the error
  4667.        occurred.
  4668.  
  4669.        The second argument is the number of the offending field entry.
  4670.  
  4671.        The third argument is the type of error that occurred.  If the
  4672.        error occurred because the minimum number of characters were not
  4673.        entered, this value is the constant FIELD_MINCHARS_ERROR.  If
  4674.        the error was caused because the input conflicts with the
  4675.        regular expression, this value is the constant
  4676.        FIELD_REGEXP_ERROR.
  4677.  
  4678.        The fourth argument is the string that was entered in the field.
  4679.  
  4680.        The fifth argument depends on the type of error.  If the error
  4681.        is a FIELD_MINCHARS_ERROR error, this value is the minimum
  4682.        number of characters expected.  If the error is a
  4683.        FIELD_REGEXP_ERROR error this value is the position in string
  4684.        that does not match the regular expression.  Position numbers in
  4685.        the string start from 0.
  4686.  
  4687.  
  4688.        Return Values for User Written Function
  4689.        ---------------------------------------
  4690.  
  4691.        You MUST return a value back to the form manager if your
  4692.        user-defined error function is called.  There are two possible
  4693.        return values, FIELD_ERROR and FIELD_ACCEPT.  FIELD_ERROR tells
  4694.        the form manager to edit the field again i.e. let the user
  4695.        correct his/her error.  The FIELD_ACCEPT return value accepts
  4696.        the input, even though there is an error.
  4697.  
  4698.        Here is an example:
  4699.  
  4700.        #include <stdio.h>
  4701.        #include "cwlwin.h"
  4702.  
  4703.  
  4704.          Page 75          The C Window Library                 Page 75
  4705.  
  4706.        #define NORM  CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  4707.        #define REVERSE CREATE_VIDEO_ATTRIBUTE(WHITE_,BLACK_)
  4708.        #define WHITEONRED CREATE_VIDEO_ATTRIBUTE(RED_,WHITE_)
  4709.        #define NUMPROMPTS 8
  4710.  
  4711.        FIELD_ENTRY field_array[] =
  4712.        {CWL_INTEGER,0,35,"___",'_',1,3,NO_FIELD_OPTIONS,0,REVERSE,"3[0-9]",
  4713.        CWL_INTEGER,1,35,"___",'_',1,3,NO_FIELD_OPTIONS,0,REVERSE,"3[0-9]",
  4714.        CWL_INTEGER,2,35,"___",'_',1,3,NO_FIELD_OPTIONS,0,REVERSE,"3[0-9]",
  4715.        CWL_INTEGER,3,35,"___",'_',1,3,NO_FIELD_OPTIONS,0,REVERSE,"3[0-9]",
  4716.        CWL_INTEGER,4,35,"___",'_',1,3,NO_FIELD_OPTIONS,0,REVERSE,"3[0-9]",
  4717.        CWL_INTEGER,5,35,"___",'_',1,3,NO_FIELD_OPTIONS,0,REVERSE,"3[0-9]",
  4718.        CWL_INTEGER,6,35,"___",'_',1,3,NO_FIELD_OPTIONS,0,REVERSE,"3[0-9]",
  4719.        CWL_INTEGER,7,35,"___",'_',1,3,NO_FIELD_OPTIONS,0,REVERSE,"3[0-9]",
  4720.        FIELDEND};
  4721.  
  4722.        FORMPTR form;
  4723.        WPOINTER w, error_win;
  4724.  
  4725.        char *prompt = "Enter a number :";
  4726.  
  4727.        int display_error();
  4728.  
  4729.        main()
  4730.        {
  4731.          int i;
  4732.          WindowInitializeSystem();
  4733.          FormInitializeSystem();
  4734.          WindowInitDesktop(0);
  4735.  
  4736.          w = WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,78,22,NORM,
  4737.                               NORM,SINGLEBOX);
  4738.  
  4739.          error_win =
  4740.          WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,78,22,WHITEONRED,
  4741.                           WHITEONRED, SINGLEBOX);
  4742.  
  4743.          /* write prompts to the form window */
  4744.          for (i=0;i<NUMPROMPTS;i++)
  4745.          WindowWriteString(w,prompt,i,0);
  4746.  
  4747.          /* initialize form */
  4748.          form = FormInitialize(w,field_array,FORM_HIGHLIGHT);
  4749.  
  4750.          /* initialize error function */
  4751.          CWLedit_error_func = display_error;
  4752.  
  4753.          /* get form info */
  4754.          FormGetInput(form,1,0);
  4755.        }
  4756.  
  4757.  
  4758.  
  4759.  
  4760.  
  4761.  
  4762.  
  4763.  
  4764.          Page 76          The C Window Library                 Page 76
  4765.  
  4766.        /* This is called if there is an editing error */
  4767.        int display_error(FORMPTR form, int entry, int errval,
  4768.                          char *str, int pos)
  4769.        {
  4770.          char buf[80];
  4771.          WindowClear(error_win);
  4772.          switch (errval)
  4773.          {
  4774.            case FIELD_MINCHARS_ERROR:  /* not enough characters */
  4775.              sprintf(buf,
  4776.              "You must enter at least %d characters in this field",pos);
  4777.            break;
  4778.  
  4779.            case FIELD_REGEXP_ERROR:    /* regular expression error */
  4780.              sprintf(buf,"Invalid character entered in position %d",pos);
  4781.            break;
  4782.  
  4783.          }
  4784.  
  4785.          /* display window and return to form manager */
  4786.  
  4787.          WindowWriteCenterString(w,buf,2);
  4788.          WindowWriteCenterString(error_win,
  4789.                "Press Any Key to Continue...",4);
  4790.          WindowDisplay(error_win,1,EXPLODE);
  4791.          MakeSound(300,500);
  4792.          GET_KEY();
  4793.          WindowHide(error_window,CONTRACT);
  4794.          return FIELD_ERROR;
  4795.        }
  4796.  
  4797.  
  4798.        If the CWLedit_error_func points to a NULLFN, no function is
  4799.        called.
  4800.  
  4801.  
  4802.  
  4803.  
  4804.  
  4805.  
  4806.  
  4807.  
  4808.  
  4809.  
  4810.  
  4811.  
  4812.  
  4813.  
  4814.  
  4815.  
  4816.  
  4817.  
  4818.  
  4819.  
  4820.  
  4821.  
  4822.  
  4823.  
  4824.          Page 77          The C Window Library                 Page 77
  4825.  
  4826.                           USER DEFINED ERROR CHECKING
  4827.                           ---------------------------
  4828.  
  4829.        This section discusses the way to have a user-defined error
  4830.        checking function.  This function checks errors that The C Data
  4831.        Forms Library could not possibly do internally.  This includes
  4832.        checking the input for valid names, passwords, etc.
  4833.  
  4834.        The FormSetFieldValidateFunction() function
  4835.        -------------------------------------------
  4836.  
  4837.        The FormSetFieldValidateFunction() allows the programmer to
  4838.        assign a validation function to a field.  Here is the prototype:
  4839.  
  4840.        int FormSetFieldValidateFunction(FORMPTR form, int entrynum,
  4841.                                         int (*func)(FORMPTR cform,
  4842.                                                     int centry,
  4843.                                                     char *str))
  4844.  
  4845.        The first argument is the pointer to a form.  The second
  4846.        argument is the entry number to assign the function to.
  4847.  
  4848.        The third argument is a pointer to the user-defined function.
  4849.        This function should allow three arguments.  The first and
  4850.        second are the pointer to the form, and the field entry number.
  4851.        The last argument is the string entered in the field.
  4852.  
  4853.  
  4854.  
  4855.        Return Values for the user defined error function
  4856.        -------------------------------------------------
  4857.  
  4858.        You MUST return a value back to the form manager if your
  4859.        user-defined validation function is called.  There are two
  4860.        possible return values, FIELD_ERROR and FIELD_ACCEPT.
  4861.        FIELD_ERROR tells the form manager that there was an error, and
  4862.        to edit the field again i.e. let the user correct his/her error.
  4863.        The FIELD_ACCEPT return value accepts the input as valid.
  4864.  
  4865.        #include <stdio.h>
  4866.        #include "cwlwin.h"
  4867.        #include <stdlib.h>
  4868.  
  4869.        #define NORM  CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  4870.        #define REVERSE CREATE_VIDEO_ATTRIBUTE(WHITE_,BLACK_)
  4871.        #define WHITEONRED CREATE_VIDEO_ATTRIBUTE(RED_,WHITE_)
  4872.        #define NUMPROMPTS 8
  4873.        FIELD_ENTRY field_array[] =
  4874.        {CWL_INTEGER,0,35,"___",'_',1,3,NO_FIELD_OPTIONS,0,REVERSE,"3[0-9]",
  4875.        CWL_INTEGER,1,35,"___",'_',1,3,NO_FIELD_OPTIONS,0,REVERSE,"3[0-9]",
  4876.        CWL_INTEGER,2,35,"___",'_',1,3,NO_FIELD_OPTIONS,0,REVERSE,"3[0-9]",
  4877.        CWL_INTEGER,3,35,"___",'_',1,3,NO_FIELD_OPTIONS,0,REVERSE,"3[0-9]",
  4878.        CWL_INTEGER,4,35,"___",'_',1,3,NO_FIELD_OPTIONS,0,REVERSE,"3[0-9]",
  4879.        CWL_INTEGER,5,35,"___",'_',1,3,NO_FIELD_OPTIONS,0,REVERSE,"3[0-9]",
  4880.        CWL_INTEGER,6,35,"___",'_',1,3,NO_FIELD_OPTIONS,0,REVERSE,"3[0-9]",
  4881.        CWL_INTEGER,7,35,"___",'_',1,3,NO_FIELD_OPTIONS,0,REVERSE,"3[0-9]",
  4882.        FIELDEND};
  4883.  
  4884.          Page 78          The C Window Library                 Page 78
  4885.  
  4886.        FORMPTR form;
  4887.        WPOINTER w, error_win;
  4888.  
  4889.        char *prompt = "Enter a number :";
  4890.  
  4891.        int display_error();
  4892.  
  4893.        main()
  4894.        {
  4895.          int i;
  4896.          WindowInitializeSystem();
  4897.          FormInitializeSystem();
  4898.          WindowInitDesktop(0);
  4899.  
  4900.          w = WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,78,22,NORM,
  4901.                               NORM,SINGLEBOX);
  4902.  
  4903.          error_win =
  4904.          WindowInitialize(DESKTOP_WINDOW,BORDER,9,0,78,8,WHITEONRED,
  4905.                           WHITEONRED,SINGLEBOX);
  4906.  
  4907.          /* write prompts to the form window */
  4908.          for (i=0;i<NUMPROMPTS;i++)
  4909.            WindowWriteString(w,prompt,i,0);
  4910.  
  4911.          /* initialize form */
  4912.          form = FormInitialize(w,field_array,FORM_HIGHLIGHT);
  4913.  
  4914.          /* initialize validation function */
  4915.          for (i=0;i<NUMPROMPTS;i++)
  4916.            FormSetFieldValidateFunction(form,i,check_range);
  4917.  
  4918.          /* get form info */
  4919.          FormGetInput(form,1,0);
  4920.        }
  4921.  
  4922.  
  4923.        /* This is called to check the range */
  4924.  
  4925.        int check_range(FORMPTR form, int entry, char *str)
  4926.        {
  4927.          int num;
  4928.          WindowClear(error_win);
  4929.          num = atoi(str);
  4930.  
  4931.          /* check and display error window if out of range */
  4932.          if (num < 1 || num > 500)
  4933.          {
  4934.            WindowPrintf(error_win,
  4935.                    "The number entered %s, must be between %d and %d",
  4936.                         str,LOWLIM,HILIM);
  4937.            WindowWriteCenterString(error_win,
  4938.                    "Press Any Key to Continue...",4);
  4939.            WindowDisplay(error_win,1,EXPLODE);
  4940.            MakeSound(300,500);
  4941.  
  4942.  
  4943.  
  4944.          Page 79          The C Window Library                 Page 79
  4945.  
  4946.            GET_KEY();
  4947.            WindowHide(error_win,CONTRACT);
  4948.            /* re-edit this field */
  4949.            return FIELD_ERROR;
  4950.          }
  4951.          else
  4952.          /* field OK */
  4953.            return FIELD_ACCEPT;
  4954.        }
  4955.  
  4956.  
  4957.        The above example tests each field to make sure the input falls
  4958.        between 1 and 500.  If not, an error window is displayed and
  4959.        FIELD_ERROR is returned to the form manager.  If the field is in
  4960.        range, FIELD_ACCEPT is returned to the form manager.
  4961.  
  4962.        There is a better way to check if a field is included in a range
  4963.        of values.  This will be discussed later in the
  4964.        FormCheckFieldRange() function.
  4965.  
  4966.        If there are no errors, FormSetFieldValidateFunction() returns
  4967.        NO_ERROR.
  4968.  
  4969.        If there are errors, FormSetFieldValidateFunction() returns one
  4970.        of the following and sets window_error_code to one these values:
  4971.  
  4972.        UNDEFINED_FORM if the FORMPTR does not exist.
  4973.  
  4974.        UNDEFINED_FIELD if the field entry does not exist
  4975.  
  4976.  
  4977.  
  4978.        FormCheckFieldRange()
  4979.        ---------------------
  4980.  
  4981.        The FormCheckFieldRange() checks if a field's input falls within
  4982.        the range of two values.  These values can be any data type,
  4983.        except doubles (doubles are handled with a separate function).
  4984.  
  4985.        Here is the prototype:
  4986.  
  4987.           int FormCheckFieldRange(FORMPTR form, int entrynum, int
  4988.                                   options, ...)
  4989.  
  4990.        Note the last argument.  The prototype suggests that the
  4991.        argument is optional, but not really.  The '...' means that
  4992.        there are two values expected.  The first value is the lower
  4993.        limit, and the second value is the upper limit.  These values
  4994.        can be of any simple data type, (char, int, unsigned, etc.) as
  4995.        well as two string.
  4996.  
  4997.        The first two arguments are the pointer to the form and the
  4998.        field entry number, respectively.  The third arguments are range
  4999.        options to use.  Here are the list of range options:
  5000.  
  5001.  
  5002.  
  5003.  
  5004.          Page 80          The C Window Library                 Page 80
  5005.  
  5006.         Range Option                  Definition
  5007.         ------------                  ----------
  5008.         INCLUDE_LOW             Includes the lower limit as valid.
  5009.         INCLUDE_HIGH            Includes the upper limit as valid.
  5010.         EXCLUDE_LOW             Excludes the lower limit as valid.
  5011.         EXCLUDE_HIGH            Excludes the upper limit as valid.
  5012.         NO_RANGE_OPT            No range options (use default).
  5013.  
  5014.        INCLUDE_LOW includes the lower limit in the range check as being
  5015.        a valid number.
  5016.  
  5017.        INCLUDE_HIGH includes the upper limit in the range check as
  5018.        being a valid number.
  5019.  
  5020.        EXCLUDE_LOW does not accept any value that is equivalent to the
  5021.        lower limit.
  5022.  
  5023.        EXCLUDE_HIGH does not accept any value that is equivalent to the
  5024.        upper limit.
  5025.  
  5026.        NO_RANGE_OPT uses the default (INCLUDE_LOW | INCLUDE_HIGH).
  5027.  
  5028.        Note that the bitwise OR (|) can be used to combine options.
  5029.        INCLUDE...  options override EXCLUDE... options if they are both
  5030.        used simultaneously.
  5031.  
  5032.        Here are a few examples of using FormCheckFieldRange():
  5033.  
  5034.        a)  FormCheckFieldRange(form,0,NO_RANGE_OPT,100,200)
  5035.  
  5036.        b)  FormCheckFieldRange(form,1,NO_RANGE_OPT,-1, 50)
  5037.  
  5038.        c)  FormCheckFieldRange(form,3,EXCLUDE_LOW,'a','z')
  5039.  
  5040.        d)  FormCheckFieldRange(form,2,NO_RANGE_OPT,"abc","def");
  5041.  
  5042.  
  5043.        a) Tests if the value entered in field 0 is between 100 and 200,
  5044.           inclusive.
  5045.        b) Tests if the value entered in field 1 is between -1 and 50,
  5046.           inclusive.
  5047.        c) Tests if the single value entered in field 1 is
  5048.           between 'a' and 'z', but not including 'a'.
  5049.        d) Tests if the string entered is between "abc" and "def"
  5050.           inclusive.
  5051.  
  5052.        When the test is made, a value is returned that tells how the
  5053.        test turned out.
  5054.  
  5055.        Value returned                    Definition
  5056.        --------------                    ----------
  5057.  
  5058.        FIELD_LOW                      Field value is too small.
  5059.        FIELD_HIGH                     Field value is too large.
  5060.        FIELD_OUT_OF_RANGE             Field is either too small or too
  5061.                                       large.
  5062.        FIELD_OK                       Field is in range.
  5063.  
  5064.          Page 81          The C Window Library                 Page 81
  5065.  
  5066.        If there are no errors, FormCheckFieldRange() returns one of the
  5067.        values above.
  5068.  
  5069.        If there are errors other than the ones mentioned above,
  5070.        FormCheckFieldRange() returns one of the following and sets
  5071.        window_error_code to one these values:
  5072.  
  5073.        UNDEFINED_FORM if the FORMPTR does not exist.
  5074.  
  5075.        UNDEFINED_FIELD if the field entry does not exist
  5076.  
  5077.  
  5078.  
  5079.  
  5080.  
  5081.  
  5082.  
  5083.  
  5084.  
  5085.  
  5086.  
  5087.  
  5088.  
  5089.  
  5090.  
  5091.  
  5092.  
  5093.  
  5094.  
  5095.  
  5096.  
  5097.  
  5098.  
  5099.  
  5100.  
  5101.  
  5102.  
  5103.  
  5104.  
  5105.  
  5106.  
  5107.  
  5108.  
  5109.  
  5110.  
  5111.  
  5112.  
  5113.  
  5114.  
  5115.  
  5116.  
  5117.  
  5118.  
  5119.  
  5120.  
  5121.  
  5122.  
  5123.  
  5124.          Page 82          The C Window Library                 Page 82
  5125.  
  5126.                              CLEARING A FORM
  5127.                              ---------------
  5128.  
  5129.        FormClear()
  5130.        -----------
  5131.  
  5132.        You can clear a form of all input and move the input cursor to
  5133.        any field using the FormClear() function.  Here is the
  5134.        prototype:
  5135.  
  5136.                int FormClear(FORMPTR form, int entry)
  5137.  
  5138.        The first argument is the pointer to the form, and the second
  5139.        argument is the entry to place the input cursor when the form is
  5140.        cleared.  If the entry is protected, the form manager tries to
  5141.        find the next available field.  The number of characters that is
  5142.        cleared is determined by the visible width of the input field.
  5143.  
  5144.  
  5145.  
  5146.        If there is no error, FormClear() returns NO_ERROR.
  5147.  
  5148.        If there are errors FormClear() returns the following and sets
  5149.        window_error_code to this value:
  5150.  
  5151.        UNDEFINED_FORM if the FORMPTR does not exist.
  5152.  
  5153.  
  5154.  
  5155.  
  5156.  
  5157.  
  5158.  
  5159.  
  5160.  
  5161.  
  5162.  
  5163.  
  5164.  
  5165.  
  5166.  
  5167.  
  5168.  
  5169.  
  5170.  
  5171.  
  5172.  
  5173.  
  5174.  
  5175.  
  5176.  
  5177.  
  5178.  
  5179.  
  5180.  
  5181.  
  5182.  
  5183.  
  5184.          Page 83          The C Window Library                 Page 83
  5185.  
  5186.                                 EXITING A FORM
  5187.                                 --------------
  5188.  
  5189.        When the last input field is edited, or the form is exited
  5190.        prematurely, an exit function can be called before the form is
  5191.        actually closed.
  5192.  
  5193.        FormSetExitFunction()
  5194.        ---------------------
  5195.  
  5196.        The FormSetExitFunction() sets up a function that will be called
  5197.        whenever a form is exited.  Here is the prototype:
  5198.  
  5199.  
  5200.        int FormSetExitFunction (FORMPTR form,
  5201.                                 int (*exit_func)(FORMPTR cform,
  5202.                                                  int status,
  5203.                                                  int *currfield))
  5204.  
  5205.        The first argument is the pointer to the form.  The second
  5206.        argument is the pointer to a user-defined exit function.  This
  5207.        function is passed three arguments from the form manager.
  5208.  
  5209.        The first argument is the current form.  The second argument is
  5210.        a status indicator that tells how the form was exited (last
  5211.        field was exited, first field was exited etc.).  Here are the
  5212.        list of status codes:
  5213.  
  5214.  
  5215.        Status Code                     Definition
  5216.        -----------                     ----------
  5217.  
  5218.        FIRST_FIELD_EXIT                Form was exited by moving the
  5219.                                        input cursor to a field before
  5220.                                        the first available field in a
  5221.                                        form.
  5222.  
  5223.        LAST_FIELD_EXIT                 Form was exited by moving the
  5224.                                        input cursor to a field after
  5225.                                        the last available field.
  5226.  
  5227.        FORM_END                        Form exited and saved by other
  5228.                                        means i.e. an accept key was hit
  5229.                                        in the middle of the form or An
  5230.                                        'OK' button was activated.
  5231.  
  5232.        FORM_CANCEL                     Form exited and potentially
  5233.                                        cancelled in the middle of the
  5234.                                        form.
  5235.  
  5236.        The third argument is a pointer to an entry number.  The
  5237.        user-defined exit function MUST return a value back to the form
  5238.        manager.  Here is a list of the valid return values:
  5239.  
  5240.        FORM_END_PROCESS - End processing of the form.
  5241.        FORM_REEDIT - Reedit the form starting at the entry number
  5242.                     assigned to the pointer *currfield.
  5243.  
  5244.        The FORM_END_PROCESS value ends the processing of the fields.
  5245.  
  5246.          Page 84          The C Window Library                 Page 84
  5247.  
  5248.        The FORM_REEDIT value tells the form manager to collect input
  5249.        again in the form, but start at the number assigned to
  5250.        *currfield.
  5251.  
  5252.        #include <stdio.h>
  5253.        #include "cwlwin.h"
  5254.        #include <stdlib.h>
  5255.  
  5256.        #define NORM  CREATE_VIDEO_ATTRIBUTE(BLACK_,WHITE_)
  5257.        #define REVERSE CREATE_VIDEO_ATTRIBUTE(WHITE_,BLACK_)
  5258.        #define WHITEONRED CREATE_VIDEO_ATTRIBUTE(RED_,WHITE_)
  5259.        #define NUMPROMPTS 8
  5260.        #define LOWLIM     1
  5261.        #define HILIM      200
  5262.  
  5263.        FIELD_ENTRY field_array[] =
  5264.        {CWL_INTEGER,0,35,"___",'_',1,3,NO_FIELD_OPTIONS,0,REVERSE,"3[0-9]",
  5265.        CWL_INTEGER,1,35,"___",'_',1,3,NO_FIELD_OPTIONS,0,REVERSE,"3[0-9]",
  5266.        CWL_INTEGER,2,35,"___",'_',1,3,NO_FIELD_OPTIONS,0,REVERSE,"3[0-9]",
  5267.        CWL_INTEGER,3,35,"___",'_',1,3,NO_FIELD_OPTIONS,0,REVERSE,"3[0-9]",
  5268.        CWL_INTEGER,4,35,"___",'_',1,3,NO_FIELD_OPTIONS,0,REVERSE,"3[0-9]",
  5269.        CWL_INTEGER,5,35,"___",'_',1,3,NO_FIELD_OPTIONS,0,REVERSE,"3[0-9]",
  5270.        CWL_INTEGER,6,35,"___",'_',1,3,NO_FIELD_OPTIONS,0,REVERSE,"3[0-9]",
  5271.        CWL_INTEGER,7,35,"___",'_',1,3,NO_FIELD_OPTIONS,0,REVERSE,"3[0-9]",
  5272.        FIELDEND};
  5273.  
  5274.        FORMPTR form;
  5275.        WPOINTER w, error_win, again_win;
  5276.  
  5277.        char *prompt = "Enter a number :";
  5278.  
  5279.        int check_range();
  5280.        int edit_again();
  5281.  
  5282.        main()
  5283.        {
  5284.          int i;
  5285.          WindowInitializeSystem();
  5286.          FormInitializeSystem();
  5287.          WindowInitDesktop(0);
  5288.  
  5289.          w = WindowInitialize(DESKTOP_WINDOW,BORDER,0,0,78,22,NORM,
  5290.                               NORM,SINGLEBOX);
  5291.  
  5292.          error_win =
  5293.          WindowInitialize(DESKTOP_WINDOW,BORDER,9,0,78,10,WHITEONRED,
  5294.                           WHITEONRED,SINGLEBOX);
  5295.  
  5296.          again_win =
  5297.          WindowInitialize(DESKTOP_WINDOW,NOBORDER,24,0,80,1,
  5298.                           REVERSE,REVERSE,0);
  5299.  
  5300.          WindowWriteString(again_win,
  5301.            "Enter a field to edit or ENTER to exit the form",0,0);
  5302.  
  5303.          /* write prompts to the form window */
  5304.          for (i=0;i<NUMPROMPTS;i++)
  5305.            WindowWriteString(w,prompt,i,0);
  5306.  
  5307.          Page 85          The C Window Library                 Page 85
  5308.  
  5309.          /* initialize form */
  5310.          form = FormInitialize(w,field_array,FORM_HIGHLIGHT);
  5311.  
  5312.          /* initialize exit function */
  5313.          FormSetExitFunction(form,edit_again);
  5314.  
  5315.          FormSetFieldOptions(form,0,FIELD_PROTECT,1);
  5316.  
  5317.          /* initialize validation function */
  5318.          for (i=0;i<NUMPROMPTS;i++)
  5319.          FormSetFieldValidateFunction(form,i,check_range);
  5320.  
  5321.          /* get form info */
  5322.          FormGetInput(form,1,0);
  5323.        }
  5324.  
  5325.  
  5326.        /* This is called if there is an editing error */
  5327.  
  5328.        int check_range(FORMPTR form, int entry, char *str)
  5329.        {
  5330.          int num;
  5331.          WindowClear(error_win);
  5332.          num = atoi(str);
  5333.  
  5334.         /* check and display error window if out of range */
  5335.         if (num < LOWLIM || num > HILIM)
  5336.         {
  5337.           WindowPrintf(error_win,"The number entered %s is out of range\n"
  5338.                                  "The number must be between %d and %d",
  5339.                                  str,LOWLIM,HILIM);
  5340.           WindowWriteCenterString(error_win,
  5341.                                   "Press Any Key to Continue...",4);
  5342.           WindowDisplay(error_win,1,EXPLODE);
  5343.           MakeSound(300,500);
  5344.           GET_KEY();
  5345.           WindowHide(error_win,CONTRACT);
  5346.  
  5347.          /* re-edit this field */
  5348.           return FIELD_ERROR;
  5349.         }
  5350.         else
  5351.  
  5352.          /* field OK */
  5353.         return FIELD_ACCEPT;
  5354.        }
  5355.  
  5356.        /* ask user whether they want to re-edit the form */
  5357.        int edit_again(FORMPTR form, int status, int *entry)
  5358.        {
  5359.          char buf[3];
  5360.          int num;
  5361.          buf[0] = 0;
  5362.          WindowDisplay(again_win,1,NOEFFECT);
  5363.  
  5364.  
  5365.  
  5366.  
  5367.          Page 86          The C Window Library                 Page 86
  5368.  
  5369.          /* loop until user has a viable entry or hits return */
  5370.          do
  5371.          {
  5372.            WindowGetString(again_win,0,49,buf,'_',0,2,NO_OPTIONS,0,
  5373.                            "2[0-9]");
  5374.            num = atoi(buf);
  5375.          } while (!((num >= 1 && num <= NUMPROMPTS) || buf[0] == 0));
  5376.          WindowHide(again_win,NOEFFECT);
  5377.  
  5378.          /* return hit, so quit */
  5379.          if (buf[0] == 0)
  5380.            return FORM_END_PROCESS;
  5381.          else
  5382.          {
  5383.            /* assign entry number and return */
  5384.           *entry = num - 1;
  5385.           return FORM_REEDIT;
  5386.          }
  5387.        }
  5388.  
  5389.  
  5390.        The example above makes use of the exit function by asking the
  5391.        user whether he/she wants to edit another field.  If the field
  5392.        number entered is in range, edit_again() returns a FORM_REEDIT
  5393.        to the form manager, as well as assigns the appropriate field
  5394.        number.
  5395.  
  5396.        If the field number that is assigned to *entry is out of bounds,
  5397.        the form manager will always start editing input from the first
  5398.        available field.
  5399.  
  5400.  
  5401.        If there is no error, FormSetExitFunction() returns NO_ERROR.
  5402.  
  5403.        If there are errors FormSetExitFunction() returns the following
  5404.        and sets window_error_code to this value:
  5405.  
  5406.        UNDEFINED_FORM if the FORMPTR does not exist.
  5407.  
  5408.  
  5409.  
  5410.  
  5411.  
  5412.  
  5413.  
  5414.  
  5415.  
  5416.  
  5417.  
  5418.  
  5419.  
  5420.  
  5421.  
  5422.  
  5423.  
  5424.  
  5425.  
  5426.  
  5427.  
  5428.          Page 87          The C Window Library                 Page 87
  5429.  
  5430.                               DISPOSING OF A FORM
  5431.                               -------------------
  5432.  
  5433.        If a form is no longer needed, all memory allocated to the form
  5434.        should be returned to the heap.
  5435.  
  5436.        FormClose()
  5437.        -----------
  5438.  
  5439.        The FormClose() function deallocates all memory allocated to the
  5440.        form, and makes the FORMPTR invalid.  Here is the prototype:
  5441.  
  5442.                        int FormClose(FORMPTR form)
  5443.  
  5444.        The only argument is the pointer to the form.  Once this
  5445.        function is called, the FORMPTR cannot be used unless it is
  5446.        assigned to a valid form.
  5447.  
  5448.  
  5449.        If there is no error, FormClose() returns NO_ERROR.
  5450.  
  5451.        If there are errors FormClose() returns the following and sets
  5452.        window_error_code to this value:
  5453.  
  5454.        UNDEFINED_FORM if the FORMPTR does not exist.
  5455.  
  5456.  
  5457.  
  5458.  
  5459.  
  5460.  
  5461.  
  5462.  
  5463.  
  5464.  
  5465.  
  5466.  
  5467.  
  5468.  
  5469.  
  5470.  
  5471.  
  5472.  
  5473.  
  5474.  
  5475.  
  5476.  
  5477.  
  5478.  
  5479.  
  5480.  
  5481.  
  5482.  
  5483.  
  5484.  
  5485.  
  5486.  
  5487.  
  5488.          Page 88          The C Window Library                 Page 88
  5489.  
  5490.                               USING A MOUSE
  5491.                               -------------
  5492.  
  5493.        Using the mouse
  5494.        ---------------
  5495.  
  5496.        You can now use a Microsoft compatible mouse to go from field to
  5497.        field by clicking the left mouse button on any unprotected
  5498.        field.  You can also move the cursor within a field using the
  5499.        mouse.
  5500.  
  5501.  
  5502.  
  5503.        Setting up to use the mouse
  5504.        ---------------------------
  5505.  
  5506.        To use the mouse, you must do three things.
  5507.  
  5508.         b) Call MouseInitializeSystem().
  5509.  
  5510.         c) Call the FormSetMouse() function.
  5511.  
  5512.  
  5513.        The MouseInitializeSystem() function is described in The C
  5514.        Window Library manual.  It must be called with
  5515.        MOUSE_FULL_INSTALL as the first argument for the mouse to be
  5516.        used with Data Forms.
  5517.  
  5518.        Once this is done, a call to FormSetMouse() must be made after
  5519.        the form is initialized with FormInitialize().  Here is the
  5520.        prototype to this function:
  5521.  
  5522.        int FormSetMouse(FORMPTR form, int opt)
  5523.  
  5524.        The first argument is the form to set the mouse for, and the
  5525.        second argument is whether the mouse is to be turned on or off
  5526.        for the form.  If the second argument is TRUE, the mouse can be
  5527.        used.  If the argument is FALSE, the mouse is disabled for the
  5528.        form.  If MouseInitializeSystem() is called, the mouse will
  5529.        still be visible even if it cannot be used for a form.
  5530.  
  5531.        Remember to call MouseRestoreSystem() before your application
  5532.        terminates.
  5533.  
  5534.        FormSetMouse() returns NO_ERROR if there are no errors.  If
  5535.        there is an error, UNDEFINED_FORM is returned.
  5536.  
  5537.  
  5538.        Going from field to field with the mouse
  5539.        ----------------------------------------
  5540.  
  5541.        Once the form is activated with FormGetInput(), you can use a
  5542.        mouse to go from field to field.  There are some things that you
  5543.        must be aware of though.
  5544.  
  5545.  
  5546.  
  5547.  
  5548.          Page 89          The C Window Library                 Page 89
  5549.  
  5550.        If a field has a minimum number of characters that must be
  5551.        entered before moving to another field,  the mouse WILL NOT move
  5552.        the input cursor out of the field until the minimum number of
  5553.        characters is entered.  The only thing that can override this
  5554.        are the FIELD_OVERRIDE...() macros defined in The C Data Forms
  5555.        manual.
  5556.  
  5557.        If the field type is CWL_SUBFORM, you cannot access the parent
  5558.        form with the mouse even if both forms are visible on the
  5559.        screen.  The parent form is the form that called the subform.
  5560.        As of this version, the mouse can only be used in one form at a
  5561.        time.  If you want to exit the subform so that you can go back
  5562.        to the parent form, you should create a CWL_BUTTON field in the
  5563.        subform that when selected will close the subform and return to
  5564.        the parent form.
  5565.  
  5566.        If the field is a CWL_TOGGLE field, clicking the mouse will
  5567.        accept the current choice that is displayed.
  5568.  
  5569.        If the field is a CWL_BUTTON field, clicking the mouse will
  5570.        accept the action of the CWL_BUTTON field.
  5571.  
  5572.        If the field is a RADIO field, clicking the mouse will choose
  5573.        whatever active radio entry that the mouse is on.  The prompt
  5574.        string for the RADIO_ENTRY determines where the mouse will be
  5575.        sensed for each RADIO_ENTRY.  In other words, if your prompt
  5576.        string is "Files Menu" and this is located at (1,1) of the form,
  5577.        the mouse will be sensed for this RADIO_ENTRY when it falls in
  5578.        the prompt's area on the screen, which is row 1 and columns 1
  5579.        through 10 of the form window.
  5580.  
  5581.        CWL_CHECKBOX fields work the same as the CWL_RADIO fields except
  5582.        that clicking the mouse will toggle the field on or off.
  5583.  
  5584.        If the field type is one of the 'normal' fields, i.e.
  5585.        CWL_STRING, CWL_INTEGER, CWL_DOUBLE, CWL_CHAR, etc.  The cursor
  5586.        can be moved to different parts of the input field by clicking
  5587.        the mouse in a different location in the input field.
  5588.  
  5589.        If the mouse is clicked on a PROTECTed field, or in an area of
  5590.        the form that is not occupied by any fields, nothing happens and
  5591.        the input continues.  In a future release, you will be able to
  5592.        act on this 'errant' mouse click before Data Forms takes over.
  5593.  
  5594.  
  5595.  
  5596.        Changing the mouse defaults
  5597.        ---------------------------
  5598.  
  5599.        By default, the left mouse button is held down when moving form
  5600.        between fields.  If you prefer a different button to be used to
  5601.        move the input cursor, you can change the button by changing the
  5602.        following global variable:
  5603.  
  5604.  
  5605.  
  5606.  
  5607.  
  5608.          Page 90          The C Window Library                 Page 90
  5609.  
  5610.            int CWLfield_button_press - holds the current button to be
  5611.                                        used to move the input cursor in
  5612.                                        a form.
  5613.  
  5614.        The following constants can be assigned to this variable:
  5615.  
  5616.                    Constant              Definition
  5617.                    --------              ----------
  5618.                   MOUSELEFT_PRESS        Left button.
  5619.                   MOUSERIGHT_PRESS       Right button.
  5620.                   MOUSEMIDDLE_PRESS      Middle button.
  5621.  
  5622.        By default, CWLfield_button_press is assigned MOUSELEFT_PRESS.
  5623.        Here is an example of changing this variables:
  5624.  
  5625.        #include "cwlwin.h"
  5626.  
  5627.        main()
  5628.        {
  5629.             ...
  5630.  
  5631.          MouseInitializeSystem(  /* arguments */ );
  5632.          FormInitializeSystem();
  5633.          /* change mouse menu buttons */
  5634.          CWLfield_button_press = MOUSERIGHT_PRESS;
  5635.             ...
  5636.        }
  5637.  
  5638.        field_button_press is assigned their default values when
  5639.        MouseInitializeSystem() is called.  If you want to change
  5640.        this variables, make sure that the change is made after
  5641.        calling MouseInitializeSystem() and FormInitializeSystem().
  5642.  
  5643.  
  5644.  
  5645.  
  5646.  
  5647.  
  5648.  
  5649.  
  5650.  
  5651.  
  5652.  
  5653.  
  5654.  
  5655.  
  5656.  
  5657.  
  5658.  
  5659.  
  5660.  
  5661.  
  5662.  
  5663.  
  5664.  
  5665.  
  5666.  
  5667.  
  5668.          Page 91          The C Window Library                 Page 91
  5669.  
  5670.                          MISCELLANEOUS FORM FUNCTIONS
  5671.                          ----------------------------
  5672.  
  5673.        FormGetFieldString()
  5674.        --------------------
  5675.  
  5676.        The FormGetFieldString() returns the input entered in the field
  5677.        buffer.  Here is the prototype:
  5678.  
  5679.        int FormGetFieldString(FORMPTR form, int entry, char *buffer)
  5680.  
  5681.        The first two arguments are the FORMPTR and field entry number.
  5682.        The third argument is the pointer to a buffer that the field
  5683.        data will be copied to.  The buffer must be large enough to hold
  5684.        the string plus 1 for the null byte.
  5685.  
  5686.        If there is no error, FormGetFieldString() returns NO_ERROR.
  5687.  
  5688.        If there are errors, FormGetFieldString() returns one of the
  5689.        following and sets window_error_code to one these values:
  5690.  
  5691.        UNDEFINED_FORM if the FORMPTR does not exist.
  5692.        UNDEFINED_FIELD if the field entry does not exist
  5693.  
  5694.  
  5695.        FormGetFieldRowCol()
  5696.        --------------------
  5697.  
  5698.        The FormGetFieldRowCol() function returns the coordinates of a
  5699.        field in a viewport.  This function is useful if you have a
  5700.        virtual form, and want to know where the field is located in the
  5701.        viewport, and not the virtual window.  Here is the prototype:
  5702.  
  5703.        int FormGetFieldRowCol(FORMPTR form, int entry, unsigned *row,
  5704.                                unsigned *col)
  5705.  
  5706.        The *row and *col arguments are pointers to integers that will
  5707.        store the row and column of the field, respectively.
  5708.  
  5709.        Since virtual forms can scroll left, right, up, or down,
  5710.        depending on where the field is, this function can be useful to
  5711.        pinpoint where the field is located in the viewport.  If the
  5712.        form is a simple windowed form, *row and *col will just contain
  5713.        the row and column of the field when initialized.
  5714.  
  5715.        If there is no error, FormGetFieldRowCol() returns NO_ERROR.
  5716.  
  5717.        If there are errors, FormGetFieldRowCol() returns one of the
  5718.        following and sets window_error_code to one these values:
  5719.  
  5720.        UNDEFINED_FORM if the FORMPTR does not exist.
  5721.  
  5722.        UNDEFINED_FIELD if the field entry does not exist
  5723.  
  5724.        FIELD_NOT_IN_VIEW if the field is not currently displayed in the
  5725.        viewport.  If this error occurs, *row and *col are invalid and
  5726.        should not be used.
  5727.  
  5728.          Page 91          The C Window Library                 Page 91
  5729.  
  5730.                                FORM MACROS
  5731.                                -----------
  5732.  
  5733.        Most of these macros use individual FIELD_ENTRY's as an
  5734.        argument.  You should use the GET_FIELD_FROM_FORM() macro to get
  5735.        individual field entries from a form.  An example will follow
  5736.        the first two macro definitions to illustrate how to get an
  5737.        individual FIELD_ENTRY.
  5738.  
  5739.  
  5740.  
  5741.  
  5742.  
  5743.        GET_FIELD_FROM_FORM(form,entry) - returns the FIELD_ENTRY for a
  5744.                                        form.  This macro simplifies
  5745.                                        getting individual FIELD_ENTRY's
  5746.                                        from an array of field entries.
  5747.  
  5748.        FIELD_PROTECT_ON(entry)         - returns 1 if the FIELD_ENTRY
  5749.                                        entry has the FIELD_PROTECT option
  5750.                                        on, 0 otherwise.
  5751.  
  5752.  
  5753.        Example:
  5754.  
  5755.  
  5756.        FIELD_ENTRY fields[] = { /* ... List of field entries ... */};
  5757.  
  5758.                /* other stuff */
  5759.  
  5760.        FORMPTR form;
  5761.  
  5762.        main()
  5763.        {
  5764.        int is_on;
  5765.        FIELD_ENTRY fe;
  5766.  
  5767.        .
  5768.        .
  5769.        .
  5770.  
  5771.        /* Here is one way to get the third FIELD_ENTRY in the
  5772.           fields array */
  5773.  
  5774.        fe = fields[2];  /* Gets the third field entry in array fields */
  5775.        is_on = FIELD_PROTECT_ON(fe);
  5776.  
  5777.        /* Here is another way to get the third field entry, given that the
  5778.        form exists and it was initialized with the fields array */
  5779.  
  5780.        fe = GET_FIELD_FROM_FORM(form,2);
  5781.        is_on = FIELD_PROTECT_ON(fe);
  5782.  
  5783.        }
  5784.  
  5785.  
  5786.  
  5787.  
  5788.          Page 92          The C Window Library                 Page 92
  5789.  
  5790.        Remember when accessing FIELD_ENTRY's directly from the array, the
  5791.        first FIELD_ENTRY is 0, the second is FIELD_ENTRY 1, etc.
  5792.  
  5793.  
  5794.        FIELD_COMMA_ON(entry) - returns 1 if the FIELD_ENTRY entry has
  5795.                                the FIELD_COMMA option on, 0 otherwise.
  5796.  
  5797.        FIELD_RJUSTIFY_ON(entry) - returns 1 if the FIELD_ENTRY entry
  5798.                                has the FIELD_RJUSTIFY option on, 0
  5799.                                otherwise.
  5800.  
  5801.        FIELD_LJUSTIFY_ON(entry) - returns 1 if the FIELD_ENTRY entry
  5802.                                has the FIELD_LJUSTIFY option on, 0
  5803.                                otherwise.
  5804.  
  5805.        FIELD_UPPERCASE_ON(entry) - returns 1 if the FIELD_ENTRY entry
  5806.                                has the FIELD_UPPERCASE option on, 0
  5807.                                otherwise.
  5808.  
  5809.        FIELD_LOWERCASE_ON(entry) - returns 1 if the FIELD_ENTRY entry
  5810.                                has the FIELD_LOWERCASE option on, 0
  5811.                                otherwise.
  5812.  
  5813.        FIELD_CHECKSPACES_ON(entry) - returns 1 if the FIELD_ENTRY entry
  5814.                                has the FIELD_CHECKSPACES option on, 0
  5815.                                otherwise.
  5816.  
  5817.        FIELD_ENHANCEDKEY_ON(entry) - returns 1 if the FIELD_ENTRY entry
  5818.                                has the FIELD_ENHANCEDKEY option on, 0
  5819.                                otherwise.
  5820.  
  5821.        FIELD_CHECKREGEXP_ON(entry) - returns 1 if the FIELD_ENTRY entry
  5822.                                has the FIELD_CHECKREGEXP option on, 0
  5823.                                otherwise.
  5824.  
  5825.        FIELD_AUTORETURN_ON(entry) - returns 1 if the FIELD_ENTRY entry
  5826.                                has the FIELD_AUTORETURN option on, 0
  5827.                                otherwise.
  5828.  
  5829.        FIELD_CHECKREGEXP_IGNORECASE_ON(entry) -  returns 1 if the
  5830.                                     FIELD_ENTRY entry has the
  5831.                                     FIELD_CHECKREGEXP_IGNORECASE
  5832.                                     option on, 0 otherwise.
  5833.  
  5834.        FIELD_FLUSHBUFFER_ON(entry) - returns 1 if the FIELD_ENTRY entry
  5835.                                has the FIELD_FLUSHBUFFER option on, 0
  5836.                                otherwise.
  5837.  
  5838.        FIELD_HOMECURSOR_ON(entry) - returns 1 if the FIELD_ENTRY entry
  5839.                                     has the FIELD_HOMECURSOR option on,
  5840.                                     0 otherwise.
  5841.  
  5842.        FIELD_ZSUPPRESS1_ON(entry) - returns 1 if the FIELD_ENTRY entry
  5843.                                     has the FIELD_ZSUPPRESS1 option on,
  5844.                                     0 otherwise.
  5845.  
  5846.        FIELD_ZSUPPRESS2_ON(entry) - returns 1 if the FIELD_ENTRY entry
  5847.                                     has the FIELD_ZSUPPRESS2 option on,
  5848.                                     0 otherwise.
  5849.  
  5850.          Page 93          The C Window Library                 Page 93
  5851.  
  5852.        FIELD_PASSWORD_ON(entry) - returns 1 if the FIELD_ENTRY entry has
  5853.                                the FIELD_PASSWORD option on, 0 otherwise.
  5854.  
  5855.  
  5856.        FIELD_OVERRIDE_FORWARD_ON(entry) - returns 1 if the FIELD_ENTRY
  5857.                                        entry has the
  5858.                                        FIELD_OVERRIDE_FORWARD option on, 0
  5859.                                        otherwise.
  5860.  
  5861.        FIELD_OVERRIDE_BACKWARD_ON(entry) - returns 1 if the FIELD_ENTRY
  5862.                                        entry has the
  5863.                                        FIELD_OVERRIDE_BACKWARD option on,
  5864.                                        0 otherwise.
  5865.  
  5866.        FIELD_CLEARFIELD_ON(entry) - returns 1 if the FIELD_ENTRY entry
  5867.                                     will be cleared if the first key
  5868.                                     hit in this field is a key
  5869.                                     recognized by the field's regular
  5870.                                     expression.
  5871.  
  5872.        FORM_DIRECTION(form) -
  5873.                returns FORM_FORWARD if the user is moving the input cursor
  5874.                towards the last field in the form, FORM_BACKWARD if the
  5875.                user is moving the form input cursor toward the first
  5876.                field.  If the FORM_WRAP option is on, FORM_DIRECTION()
  5877.                does not change if the form has wrapped to the first or
  5878.                last available field.
  5879.  
  5880.        This macro is useful if you want to invoke a pre or post-input
  5881.        function only if the user is moving toward the last field and not
  5882.        if they are going toward the first field.
  5883.  
  5884.  
  5885.        FORM_EXPLODE_TYPE(form) - returns what type of special effect will
  5886.                                be used when the form window is displayed
  5887.                                or hidden.  You can also assign values to
  5888.                                this macro.  The default value is NOEFFECT.
  5889.  
  5890.                                Example:  FORM_EXPLODE_TYPE(form) = EXPLODE;
  5891.  
  5892.        FORM_WRAP_ON(form) - returns 1 if the FORM_WRAP option is on, 0
  5893.                             otherwise.
  5894.  
  5895.        FORM_CHECK_ON(form) - returns 1 if the FORM_CHECK option is on, 0
  5896.                              otherwise.
  5897.  
  5898.        FORM_EXIT_INITIAL_ON(form) - returns 1 if the FORM_EXIT_INITIAL
  5899.                                     option is on, 0 otherwise.
  5900.  
  5901.        FORM_HIGHLIGHT_ON(form) - returns 1 if the FORM_HIGHLIGHT option is
  5902.                                  on, 0 otherwise.
  5903.  
  5904.        FORM_VIRTUAL_ON(form) - returns 1 if the form is a virtual form, 0
  5905.                                otherwise.
  5906.  
  5907.        FORM_NOEXIT_LAST_ON(form) - returns 1 if the FORM_NOEXIT_LAST
  5908.                                    option is on, 0 otherwise.
  5909.  
  5910.          Page 94          The C Window Library                 Page 94
  5911.  
  5912.        FORM_STATIC_ON(form) - returns 1 if the FORM_STATIC option is on, 0
  5913.                               otherwise.
  5914.  
  5915.        FORM_WINDOW(form) - returns the pointer (WPOINTER) to the form's
  5916.                            window.
  5917.  
  5918.        FORM_VIRTUAL_WINDOW(form) - returns the pointer (VWPOINTER) to the
  5919.                                    form's virtual window.
  5920.  
  5921.        FORM_NUMBER_OF_FIELDS(form) - returns an integer which is the
  5922.                                      number of fields in a form.
  5923.  
  5924.        FIELD_IN_RANGE(form,entry) - returns 1 if the entry number exists
  5925.                                     in a form, 0 otherwise.
  5926.  
  5927.        FIELD_ROW(entry) - returns an integer which is the row of the
  5928.                           FIELD_ENTRY entry.
  5929.  
  5930.        FIELD_COLUMN(entry) - returns an integer which is the column of the
  5931.                              FIELD_ENTRY entry.
  5932.  
  5933.        FIELD_TYPE(entry) - returns an integer denoting the field type of a
  5934.                            FIELD_ENTRY (i.e.  CWL_INTEGER, CWL_STRING, etc.)
  5935.  
  5936.        FIELD_MASK(entry) - returns a pointer (char *) to the mask string
  5937.                            used for a FIELD_ENTRY.
  5938.  
  5939.        FIELD_FILL(entry) - returns an integer that denotes the fill
  5940.                            character used for a FIELD_ENTRY.
  5941.  
  5942.        FIELD_MINIMUM(entry) - returns an integer which denotes the minimum
  5943.                               number of characters needed to be filled in
  5944.                               for a FIELD_ENTRY.
  5945.  
  5946.        FIELD_VISIBLE_WIDTH(entry) - returns an integer which is the
  5947.                                     visible width of a FIELD_ENTRY.
  5948.  
  5949.        FIELD_REGEXP(entry) - returns a pointer (char *) to the regular
  5950.                              expression string used in a FIELD_ENTRY
  5951.                              entry.
  5952.  
  5953.        FIELD_ATTRIBUTE(entry) - returns an integer which denotes the
  5954.                                 attribute used for the FIELD_ENTRY entry.
  5955.  
  5956.        FIELD_VARPTR(entry) - returns a pointer (void *) to the user's
  5957.                              variable that will hold the converted data
  5958.                              of the FIELD_ENTRY entry.
  5959.  
  5960.        FIELD_CHANGE(form,entry) - returns 1 if the data entered in the
  5961.                                   field defined by entry has been changed
  5962.                                   since editing the form, 0 otherwise.  If
  5963.                                   the form is re-edited with another call
  5964.                                   to FormGetInput(), FIELD_CHANGE() is
  5965.                                   reset to 0 for all fields in the form.
  5966.  
  5967.  
  5968.  
  5969.  
  5970.          Page 95          The C Window Library                 Page 95
  5971.  
  5972.        FORM_CHANGE(form)        - returns 1 if any fields in the form have
  5973.                                changed, 0 otherwise.  If the form is
  5974.                                re-edited with another call to
  5975.                                FormGetInput(), FORM_CHANGE() returns 0.
  5976.  
  5977.  
  5978.  
  5979.  
  5980.  
  5981.  
  5982.  
  5983.  
  5984.  
  5985.  
  5986.  
  5987.  
  5988.  
  5989.  
  5990.  
  5991.  
  5992.  
  5993.  
  5994.  
  5995.  
  5996.  
  5997.  
  5998.  
  5999.  
  6000.  
  6001.  
  6002.  
  6003.  
  6004.  
  6005.  
  6006.  
  6007.  
  6008.  
  6009.  
  6010.  
  6011.  
  6012.  
  6013.  
  6014.  
  6015.  
  6016.  
  6017.  
  6018.  
  6019.  
  6020.  
  6021.  
  6022.  
  6023.  
  6024.  
  6025.  
  6026.  
  6027.  
  6028.  
  6029.  
  6030.          Page 96          The C Window Library                 Page 96
  6031.  
  6032.                                   INDEX
  6033.                                   -----
  6034.  
  6035.          B
  6036.  
  6037.          Button Field    (see Field-Pushbutton)
  6038.  
  6039.  
  6040.          C
  6041.  
  6042.          Checkbox Field  (see Field-Checkbox)
  6043.  
  6044.  
  6045.  
  6046.          F
  6047.  
  6048.          Field
  6049.                Attributes ......................... 9
  6050.                Checkbox ........................... 34 - 39
  6051.                Comma (see Field-Options)
  6052.                Constants .......................... 5
  6053.                Creating ........................... 2  - 13
  6054.                Errors ............................. 16 - 17
  6055.                FIELD_ENTRY structure .............. 3  - 10
  6056.                Fill Character ..................... 6
  6057.                Getting Field Buffer ............... 89
  6058.                Getting Row and Column ............. 89
  6059.                Justification (see Field-Options)
  6060.                List Box ........................... 19 - 21
  6061.                Mask ............................... 6
  6062.                Maximum Width ...................... 6
  6063.                Minimum Characters allowed ......... 6
  6064.                Options ............................ 6, 56 - 57
  6065.                Proteceted (see Field-Options)
  6066.                Pushbutton ......................... 25 - 29
  6067.                Radio .............................. 30 - 34
  6068.                Range Checking ..................... 80 - 82
  6069.                Regular Expression ................. 9
  6070.                Row and Column ..................... 5
  6071.                Setting Decimal Places ............. 17 - 18
  6072.                Special Fields ..................... 19 - 39
  6073.                Starting Input Position ............ 9
  6074.                Storing Values in Field Buffer ..... 60
  6075.                Subform ............................ 23 - 25
  6076.                Toggle ............................. 21 - 23
  6077.                Types .............................. 4  - 5
  6078.                Zero Suppression (see Field-Options)
  6079.  
  6080.  
  6081.          Floating Point  (See Form-Initializing Floating Point)
  6082.  
  6083.  
  6084.  
  6085.  
  6086.  
  6087.  
  6088.  
  6089.  
  6090.          Page 97          The C Window Library                 Page 97
  6091.  
  6092.          Forms
  6093.                Clearing ........................... 83
  6094.                Disposing .......................... 88
  6095.                Exiting ............................ 84 - 87
  6096.                Form Manager ....................... 1
  6097.                Getting Input ...................... 40 - 47
  6098.                Initializing ....................... 13 - 16
  6099.                Initializing Library ............... 2
  6100.                Introduction ....................... 1
  6101.                Options ............................ 13 - 14, 58 - 59
  6102.                Virtual Scrolling .................. 41
  6103.                Editing Input ...................... 42 - 46
  6104.                Assigning Values To Fields ......... 48 - 55
  6105.                Retrieving Values From Fields ...... 50 - 55
  6106.  
  6107.  
  6108.          I
  6109.  
  6110.          Initializing
  6111.              Forms   (see Forms - Initializing)
  6112.              Library (see Forms - Initializing Library)
  6113.  
  6114.  
  6115.  
  6116.          L
  6117.  
  6118.          List Box Field  (see Field-List Box)
  6119.  
  6120.  
  6121.  
  6122.          M
  6123.  
  6124.          Macros ................................... 92 - 96
  6125.          Mouse .................................... 89 - 91
  6126.  
  6127.  
  6128.  
  6129.          R
  6130.  
  6131.          Radio Field (see Field-Radio)
  6132.          Regular Expressions
  6133.              (see Field - Regular Expressions)
  6134.  
  6135.  
  6136.  
  6137.          S
  6138.  
  6139.          Subform Field  (see Field-Subforms)
  6140.  
  6141.  
  6142.  
  6143.  
  6144.  
  6145.  
  6146.  
  6147.  
  6148.  
  6149.  
  6150.          Page 98          The C Window Library                 Page 98
  6151.  
  6152.          U
  6153.  
  6154.          User-Defined Functions
  6155.            Post-Input Function .................... 66 - 68
  6156.            Pre-Input Function ..................... 61 - 65
  6157.            Undefined Key Function ................. 69 - 72
  6158.            Error Function ......................... 73 - 82
  6159.            Exit Function .......................... 84 - 87
  6160.  
  6161.  
  6162.          V
  6163.  
  6164.          Virtual Forms  (see Forms)
  6165.  
  6166.  
  6167.  
  6168.  
  6169.  
  6170.  
  6171.  
  6172.  
  6173.  
  6174.  
  6175.  
  6176.  
  6177.  
  6178.  
  6179.  
  6180.  
  6181.  
  6182.  
  6183.  
  6184.  
  6185.  
  6186.  
  6187.  
  6188.  
  6189.  
  6190.  
  6191.  
  6192.  
  6193.  
  6194.  
  6195.  
  6196.  
  6197.  
  6198.  
  6199.  
  6200.  
  6201.  
  6202.  
  6203.  
  6204.  
  6205.  
  6206.  
  6207.  
  6208.  
  6209.  
  6210.          Page 99          The C Window Library                 Page 99
  6211.  
  6212.