home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / SCRNMS.ZIP / EDITOR.DOC next >
Text File  |  1990-03-15  |  44KB  |  1,272 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.            ---------------------------------------------------------------
  16.  
  17.                          Data Acquisition Functions Library
  18.  
  19.            ---------------------------------------------------------------
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.                      Copyright (c) 1988-90, Christopher Laforet
  36.                      Copyright (c) 1990, Chris Laforet Software
  37.                                  All Rights Reserved
  38.  
  39.  
  40.  
  41.  
  42.  
  43.           _________________________________________________________________
  44.  
  45.                                       Chapter 1                                      Chapter 1
  46.  
  47.                                     Introduction                                    Introduction
  48.           _________________________________________________________________
  49.  
  50.  
  51.                The data acquisition functions library contains a number of
  52.           important routines for the handling of database fields, as well
  53.           as some helpful utilities such as keystroke return, current
  54.           date/time clock, tone generation, and error handling.  This
  55.           library requires the support routines of the Screen and Keyboard
  56.           Library.  Notice, these routines are made exclusively for LARGE
  57.           MODEL, how else can serious applications be developed?
  58.  
  59.                This library uses my philosophy of data acquisition.  The
  60.           first step in this philosophy is that data is entered in fields
  61.           delimited by underscores.  The edit_field() function is fine-
  62.           tuned to this fact.  Why underscores?  Well underscores show
  63.           clearly the limits of a field regardless of color combinations.
  64.           It is hard to miss that the following requires a 10 character
  65.           name
  66.  
  67.                Name:  __________
  68.  
  69.           regardless of if the field is in monochrome or is in a different
  70.           color.  The second step in this philosophy is that trailing
  71.           spaces in input is to be trimmed.  There might be circumstances
  72.           when this philosophical stance is incorrect, but 99% of the time
  73.           it is true.  Hence, the edit_field() function trims off trailing
  74.           spaces.  The third step in this philosophy is that one can never
  75.           predict the future, and one might wish to take control of the
  76.           incoming data and massage it to suit one's needs!  Hence, the
  77.           edit_field() function takes a pointer to a user-defined function
  78.           which receives control every time a user presses a key.  The last
  79.           step of my philosophy is that programmers have intelligence and
  80.           since this is a fact, they have the right to control every aspect
  81.           of the data acquisition cycle.  Hence there are no extremely
  82.           high-level functions, but rather a set of mid-level tools to
  83.           assist the programmer.
  84.  
  85.                These routines are Copyrighted (c) 1988-89 by Christopher
  86.           Laforet and Copyrighted (c) 1990 by Chris Laforet Software.  All
  87.           rights are reserved by the copyright holder.  There are
  88.           absolutely no warranties implied or otherwise on these routines.
  89.           Use at your own risk.  Use them at your own risk.  While no
  90.           software can be guaranteed absolutely bug-free, these routines
  91.           have been extensively tested and work on most IBM-PC compatible
  92.           displays.  The author and copyright holder shall in no way be
  93.           held liable for any damages incurred by the use of these
  94.           routines.
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.               ---------------------------------------------------------
  102.                           Data Acquisition Functions Library                          Data Acquisition Functions Library
  103.                                         Page 2                                        Page 2
  104.  
  105.  
  106.  
  107.  
  108.           _________________________________________________________________
  109.  
  110.                                       Chapter 2                                      Chapter 2
  111.  
  112.                                 Structures and Macros                                Structures and Macros
  113.           _________________________________________________________________
  114.  
  115.  
  116.                These routines require that all compiling be done with byte
  117.           packing or alignment (-Zp1 switch in MSC 5.xx or -a in Zortech
  118.           2.xx).  Here is a listing of structures used in this library.
  119.  
  120.           struct choice
  121.                {
  122.                char choice_letter;
  123.                char *choice_string;
  124.                };
  125.  
  126.                All editing functions (edit_field() pop_menu(), and
  127.           select_menu()) return one of the following macro values which are
  128.           defined in EDITOR.H:
  129.  
  130.                E_EXIT
  131.                E_QUIT
  132.                E_END
  133.                E_FORE
  134.                E_BACK
  135.                E_PGDN
  136.                E_PGUP
  137.                ERROR
  138.  
  139.           For more information on how these returns are made, see the
  140.           chapter entitled "Keystrokes."
  141.  
  142.           The following macros are also able to be returned from the user
  143.           function passed to edit_field():
  144.  
  145.                E_INVALID - invalid keystroke
  146.                E_VALID   - valid keystroke, repaint field
  147.                E_NOPAINT - valid keystroke, do not repaint field
  148.  
  149.  
  150.                The error() function uses one of the following constants to
  151.           describe its actions:
  152.  
  153.                NOTICE    - Notify of a warning message
  154.                NON_FATAL - Indicate a non-fatal error has occurred
  155.                FATAL     - Indicate a fatal error has occurred and exit
  156.  
  157.  
  158.                The clock_flag variable can be either CLOCK_ON (1) or
  159.           CLOCK_OFF (0) depending on if the user wants the on-screen clock
  160.           to show or not.  The clock position variable is given as an int
  161.           which is composed of (row << 8) + column (see the documentation
  162.           on the screen library for more information of this format).
  163.  
  164.  
  165.  
  166.               ---------------------------------------------------------
  167.                           Data Acquisition Functions Library                          Data Acquisition Functions Library
  168.                                         Page 3                                        Page 3
  169.  
  170.  
  171.  
  172.  
  173.           _________________________________________________________________
  174.  
  175.                                       Chapter 3                                      Chapter 3
  176.  
  177.                                 Field Editing Formats                                Field Editing Formats
  178.           _________________________________________________________________
  179.  
  180.  
  181.                The edit_field() function accepts as one of its arguments a
  182.           string which describes the format of the input field from the
  183.           keyboard.
  184.  
  185.  
  186.  
  187.           3.1-Format Types          3.1-Format Types
  188.           _________________________________________________________________
  189.  
  190.  
  191.  
  192.           3.1.1-Overriding Formats          3.1.1-Overriding Formats
  193.           _________________________________________________________________
  194.  
  195.  
  196.           Format  Description
  197.           ------- ----------------------------------------------------
  198.             A     Alpha Only
  199.             0     Numeric Only
  200.             O     AlphaNumeric Only
  201.             X     Alpha and printable symbols including space
  202.             S     Alpha and space only
  203.             P     AlphaNumeric and printable symbols including space
  204.             Z     Zip+4 rules
  205.  
  206.  
  207.  
  208.           3.1.2-Format Modifiers          3.1.2-Format Modifiers
  209.           _________________________________________________________________
  210.  
  211.  
  212.           Format  Description
  213.           ------- ----------------------------------------------------
  214.             U     Uppercase all Alpha
  215.             L     Lowercase all Alpha
  216.             C     Capitalize first letters
  217.  
  218.  
  219.  
  220.           3.1.3-Extended Format Modifiers          3.1.3-Extended Format Modifiers
  221.           _________________________________________________________________
  222.  
  223.  
  224.           Format  Description
  225.           ------- ----------------------------------------------------
  226.             J     Jump over (space holder for special formats)
  227.             .     Decimal point here (field must be completely numeric)
  228.  
  229.  
  230.  
  231.               ---------------------------------------------------------
  232.                           Data Acquisition Functions Library                          Data Acquisition Functions Library
  233.                                         Page 4                                        Page 4
  234.  
  235.  
  236.  
  237.  
  238.  
  239.           3.1.4-Using Format Strings          3.1.4-Using Format Strings
  240.           _________________________________________________________________
  241.  
  242.  
  243.                There are two forms of syntax in using format strings.  The
  244.           first of these (called Format String) is a short format which
  245.           starts with the letter F (for format) is followed by an
  246.           overriding modifier and optionally by a format modifier and then
  247.           by an ascii maximum length (required).  Formats like this may be
  248.           like this:
  249.  
  250.                FAU12 - meaning up to a 12 character caps-only alpha field.
  251.                FA60  - meaning up to a 60 character (caps) alpha field.
  252.                F010  - meaning up to 10 numeric characters.
  253.  
  254.           Notice that on this type of field, length is NEVER absolute.
  255.  
  256.                The second type of format is called an Extended Format and
  257.           actually "spells out" the exact way the field is to behave.
  258.           Examples of this are:
  259.  
  260.                AA0000JA  - Caps alphas with numbers and a skipped spot.
  261.                00j00j00  - Date formatting (MM/DD/YY form).
  262.                00000.00  - Dollars and cents format (not absolute).
  263.  
  264.           Depending on their form, these formats may be absolute (all or
  265.           nothing).
  266.  
  267.  
  268.  
  269.           3.1.5-Rules for Format Strings          3.1.5-Rules for Format Strings
  270.           _________________________________________________________________
  271.  
  272.  
  273.                There are a few presumptions (rules?) used in setting up
  274.           formats which dominate their usage.
  275.  
  276.                1.  Zip+4 (Z) rules cannot be used in extended formats.
  277.                2.  Format modifiers (U,L,C) cannot be used in extended
  278.           formats.
  279.                3.  In extended formats, the case of letters is significant
  280.           for alpha locations (e.g. "AaaA" means accept alpha as upper,
  281.           lower, lower, upper).
  282.                4.  No normal format string can begin with a modifier or
  283.           extended modifier (e.g. this is illegal FCA10.  The A comes
  284.           before the C).
  285.                5.  Z and 0 type fields cannot have format modifiers (C, U,
  286.           L) in their makeup.
  287.                6.  Any error in format type will return an E_ERROR return
  288.           immediately upon calling edit_field().  You might wish to trap
  289.           for this when you first set up your functions, but remove the
  290.           trap to save code space once the function is fully debugged.
  291.  
  292.  
  293.  
  294.  
  295.  
  296.               ---------------------------------------------------------
  297.                           Data Acquisition Functions Library                          Data Acquisition Functions Library
  298.                                         Page 5                                        Page 5
  299.  
  300.  
  301.  
  302.  
  303.  
  304.           3.2-User Defined Function for Editor          3.2-User Defined Function for Editor
  305.           _________________________________________________________________
  306.  
  307.  
  308.                There is provision for a pointer to a user data handling
  309.           function to be passed to edit_field().  This function may be used
  310.           to get a specially formatted string (i.e. DOS pathname) or to
  311.           somehow massage the data in the field based on the keystroke.
  312.           This function will be called with every keystroke with a flag set
  313.           to E_VALID if the keystroke was actually utilized by the editor
  314.           or E_INVALID if it was not.  The function must return an int and
  315.           must be one of the above mentioned constants (E_VALID, E_INVALID,
  316.           or E_NOPAINT).
  317.  
  318.                Notice that when the function receives a copy of the string
  319.           being edited, it will be PACKED (that is to say, any skips
  320.           represented in extended formats with the J modifier, will not be
  321.           reflected in the string).  Also, the offset value is the offset
  322.           into the format template NOT the offset into the edited string.
  323.  
  324.                The function must return E_VALID if it doesn't want an error
  325.           beep but requests that the field be repainted and the cursor
  326.           repositioned.  It must return E_NOPAINT if the function doesn't
  327.           want the beep or a repaint.  E_INVALID is reserved as a return
  328.           requesting an error beep be sounded and the field be repainted
  329.           but the cursor remain where it was prior to calling the function.
  330.                If the function does nothing with the keystroke it must
  331.           return exactly the same constant (E_VALID or E_INVALID) as it was
  332.           passed in the action variable so that the correct default action
  333.           might be accomplished.
  334.  
  335.  
  336.  
  337.  
  338.  
  339.  
  340.  
  341.  
  342.  
  343.  
  344.  
  345.  
  346.  
  347.  
  348.  
  349.  
  350.  
  351.  
  352.  
  353.  
  354.  
  355.  
  356.  
  357.  
  358.  
  359.  
  360.  
  361.               ---------------------------------------------------------
  362.                           Data Acquisition Functions Library                          Data Acquisition Functions Library
  363.                                         Page 6                                        Page 6
  364.  
  365.  
  366.  
  367.  
  368.           _________________________________________________________________
  369.  
  370.                                       Chapter 4                                      Chapter 4
  371.  
  372.                                       Functions                                      Functions
  373.           _________________________________________________________________
  374.  
  375.  
  376.                Here is a discussion of all functions available in this
  377.           library.  NOTICE: In order to select the OS/2 library (protected
  378.           mode) you must define PROTECTED before the EDITOR.H file is
  379.           #included (e.g. #define PROTECTED or -DPROTECTED on the
  380.           compiler's command line).
  381.  
  382.  
  383.  
  384.           4.1-Field Editing Functions          4.1-Field Editing Functions
  385.           _________________________________________________________________
  386.  
  387.  
  388.           * int edit_field(int cursor,
  389.                            int hicolor,
  390.                            int locolor,
  391.                            int clock_flag,
  392.                            int clock_pos,
  393.                            int clock_color,
  394.                            char *format,
  395.                            char *string,
  396.                            int (*user_function)(int cursor,
  397.                                                 int hicolor,
  398.                                                 int locolor,
  399.                                                 int clock_flag,
  400.                                                 int clock_pos,
  401.                                                 int clock_color,
  402.                                                 char *format,
  403.                                                 char *string,
  404.                                                 int *offset,
  405.                                                 int *string_offset,
  406.                                                 int insert,
  407.                                                 int keystroke,
  408.                                                 int action));
  409.  
  410.                The edit_field() function handles the actual physical
  411.           editing of an ascii field.  It uses a format string as was
  412.           previously defined in the preceding section.  It may be passed a
  413.           pointer to a function to handle extra keystrokes or a NULL if
  414.           none is required.  The parameters to this function include offset
  415.           which is a pointer to the current format, string_offset which is
  416.           a pointer to the current offset in the string, and insert which
  417.           is TRUE is insert mode is on.  Clock flag may either be CLOCK_ON
  418.           or CLOCK_OFF.  Returns condition macro which made it exit (see
  419.           above) such as E_EXIT.  The edit field now handles decimal point
  420.           entry correctly (calculator style) with the correct formatting
  421.           (e.g. 0000.00 means 2 decimal places).
  422.  
  423.  
  424.  
  425.  
  426.               ---------------------------------------------------------
  427.                           Data Acquisition Functions Library                          Data Acquisition Functions Library
  428.                                         Page 7                                        Page 7
  429.  
  430.  
  431.  
  432.  
  433.  
  434.                If the help system is activated and if there is not already
  435.           an active topic registered, this function registers a help topic
  436.           called "field editor" so it is your responsibility to provide a
  437.           help page with this tag name.
  438.  
  439.           Example:  char fname[16];
  440.                     int rtn;
  441.                     int change = 0;
  442.  
  443.                     _vcw('_',LT_GRAY | ON_RED,0x410,15);  /* cutout */
  444.                     fname[0] = '0';
  445.                     ...
  446.                     rtn = edit_field(0x410,YELLOW | ON_RED,
  447.                          LT_GRAY | ON_RED,CLOCK_ON,0x32,
  448.                          LT_GRAY | ON_BLUE,"FAC15",fname,NULL);
  449.                     if (rtn == E_EXIT)
  450.                          change = 1;    /* editing change occurred */
  451.                     if (rtn == E_EXIT || rtn == E_FORE)
  452.                          /* move to next field */
  453.                     else if (rtn == E_BACK)
  454.                          /* move to previous field */
  455.                     else if (rtn == E_QUIT)
  456.                          /* abort the editing */
  457.                     else if (rtn == E_END)
  458.                          /* save the editing and go to next screen */
  459.  
  460.  
  461.  
  462.  
  463.  
  464.  
  465.  
  466.  
  467.  
  468.  
  469.  
  470.  
  471.  
  472.  
  473.  
  474.  
  475.  
  476.  
  477.  
  478.  
  479.  
  480.  
  481.  
  482.  
  483.  
  484.  
  485.  
  486.  
  487.  
  488.  
  489.  
  490.  
  491.               ---------------------------------------------------------
  492.                           Data Acquisition Functions Library                          Data Acquisition Functions Library
  493.                                         Page 8                                        Page 8
  494.  
  495.  
  496.  
  497.  
  498.  
  499.           * int pop_menu(int start,
  500.                          int hicolor,
  501.                          int locolor,
  502.                          char *title,
  503.                          int max_choices,
  504.                          struct choice *choices,
  505.                          int shadow,
  506.                          int space,
  507.                          int clock_flag,
  508.                          int clock_pos,
  509.                          int clock_color);
  510.  
  511.                The pop_menu() function pops up a little box with a series
  512.           of choices (with or without shadow) at the specified coordinate
  513.           and returns one of the constants mentioned above.  If the return
  514.           is greater than ascii space (0x20), then the return value
  515.           contains the ascii value of the choice made.  Choices are always
  516.           uppercased.
  517.  
  518.                If the help system is activated and if there is not already
  519.           an active topic registered, this function registers a help topic
  520.           called "popup menu" so it is your responsibility to provide a
  521.           help page with this tag name.
  522.  
  523.           Example:  struct choice yn[2] =
  524.                          {
  525.                               {'Y',"Yes"},
  526.                               {'N',"No"},
  527.                          };
  528.                     int rtn;
  529.  
  530.                     rtn = pop_menu(0x810,WHITE,LT_GRAY,"Employee?",
  531.                          2,yn,1,1,CLOCK_ON,0x32,LT_GRAY | ON_BLUE);
  532.                     if (rtn >= ' ')
  533.                          {
  534.                          if (rtn == 'Y')
  535.                               ...;
  536.                          else if (rtn == 'N')
  537.                               ...;
  538.                          rtn = E_EXIT;  /* so rtn will indicate change */
  539.                          }
  540.  
  541.  
  542.  
  543.  
  544.  
  545.  
  546.  
  547.  
  548.  
  549.  
  550.  
  551.  
  552.  
  553.  
  554.  
  555.  
  556.               ---------------------------------------------------------
  557.                           Data Acquisition Functions Library                          Data Acquisition Functions Library
  558.                                         Page 9                                        Page 9
  559.  
  560.  
  561.  
  562.  
  563.  
  564.           * int select_menu(int start,
  565.                             int hicolor,
  566.                             int locolor,
  567.                             int selcolor,
  568.                             char *title,
  569.                             int max_choices,
  570.                             char **choices,
  571.                             int width,
  572.                             int selection,
  573.                             int clock_flag,
  574.                             int clock_pos,
  575.                             int clock_color);
  576.  
  577.                The select_menu() function opens a box on the screen (with a
  578.           shadow) of specified width (if width > 30) and displays a list of
  579.           strings for selection.  If a character is hit from the keyboard
  580.           and there is a string beginning with that character, the light-
  581.           bar will go to that selection.  The choices should be sorted
  582.           alphabetically before this function is called (preferably case
  583.           insensitively).  If Enter is hit, E_EXIT will be in the lower
  584.           nibble of the return value (return & 0xf) and the upper 12 bits
  585.           (return >> 4) will have the offset of the chosen string.
  586.  
  587.                If selection is indicated other than 0, the highlight bar
  588.           will be set to that selection (1 will be the second selection,
  589.           etc).
  590.  
  591.                If the help system is activated and if there is not already
  592.           an active topic registered, this function registers a help topic
  593.           called "selection menu" so it is your responsibility to provide a
  594.           help page with this tag name.
  595.  
  596.           Example:  char *choices[5] =
  597.                          {
  598.                          "Management",
  599.                          "Clerical",
  600.                          "Maintenance",
  601.                          "Part Time Employee",
  602.                          "Other",
  603.                          };
  604.                     int rtn;
  605.                     int emp_type;
  606.  
  607.                     rtn = select_menu(0xa20,WHITE | ON_BLUE,
  608.                          LT_GRAY | ON_BLUE,WHITE | ON_RED,"Employee type",
  609.                          5,choices,30,0,CLOCK_ON,0x32,LT_GRAY | ON_BLUE);
  610.                     if ((rtn & 0xf) == E_EXIT)
  611.                          {
  612.                          emp_type = rtn >> 4;
  613.                          ...
  614.                          rtn = E_EXIT;  /* so rtn will indicate change */
  615.                          }
  616.  
  617.  
  618.  
  619.  
  620.  
  621.               ---------------------------------------------------------
  622.                           Data Acquisition Functions Library                          Data Acquisition Functions Library
  623.                                        Page 10                                       Page 10
  624.  
  625.  
  626.  
  627.  
  628.  
  629.           4.2-Special Screen Functions          4.2-Special Screen Functions
  630.           _________________________________________________________________
  631.  
  632.  
  633.           * int askyn(char *title,
  634.                       char *prompt,
  635.                       int hicolor,
  636.                       int locolor,
  637.                       int clock_flag,
  638.                       int clock_pos,
  639.                       int clock_color);
  640.  
  641.                This function opens a box in the center of the screen and
  642.           prints the title and prompt strings.  Upon receipt of a Y or an
  643.           N, the function returns 1 (Yes) or 0 (No).
  644.  
  645.           Example:  int quit = 0;
  646.  
  647.                     if (askyn("Confirm Exit","Are you SURE you want to
  648.                          exit the program?",WHITE | ON_RED,
  649.                          LT_GRAY | ON_RED,CLOCK_ON,0x32,LT_GRAY | ON_BLUE))
  650.                          {
  651.                          quit = 1;
  652.                          }
  653.  
  654.  
  655.  
  656.           * struct window *open_message(char *message,int color);
  657.  
  658.                This function blows open a window in the center of the
  659.           screen with the specified color.  It prints the message centered
  660.           in the box.  It titles the box in blinking attribute text "For
  661.           Your Information".  You can then use the update_time() function
  662.           periodically to keep the time updated.  This function is meant
  663.           for providing information while a lengthy process is being
  664.           executed.
  665.  
  666.           Example:  struct window *wndw;
  667.  
  668.                     wndw = open_message("Please wait....reindexing
  669.                          database",WHITE | ON_RED | BLINK);
  670.                     while ()  /* reindexing database */
  671.                          {
  672.                          ...
  673.                          update_time(0x32,LT_GRAY | ON_BLUE);
  674.                          }
  675.                     if (wndw)
  676.                          close_message(wndw);
  677.  
  678.  
  679.  
  680.  
  681.  
  682.  
  683.  
  684.  
  685.  
  686.               ---------------------------------------------------------
  687.                           Data Acquisition Functions Library                          Data Acquisition Functions Library
  688.                                        Page 11                                       Page 11
  689.  
  690.  
  691.  
  692.  
  693.  
  694.           * void close_message(struct window *wndw);
  695.  
  696.                This function closes a window previously opened with the
  697.           open_message() function.
  698.  
  699.           Example:  See example for open_message() function.
  700.  
  701.  
  702.  
  703.           4.3-Error Handling Functions          4.3-Error Handling Functions
  704.           _________________________________________________________________
  705.  
  706.  
  707.           * void error(int type,
  708.                        char *string,
  709.                        int clock_flag,
  710.                        int clock_pos,
  711.                        int clock_color);
  712.  
  713.                This will blow open a box in the center of the screen and
  714.           print the error message string.  If the type is E_FATAL, then the
  715.           program will terminate (using exit(1)) and the error message will
  716.           be once again be printed, this time to stderr.  The color of the
  717.           box is set by the variable __error_color which is by default set
  718.           to intense white on red.
  719.  
  720.           Example:  if (!(fd = fopen("xxx","rb")))
  721.                          error(FATAL,"Unable to open file!",0,0,0);
  722.  
  723.  
  724.           * void set_critical_error(void);
  725.           * int critical_error(int deverr,
  726.                                int errcode,
  727.                                int far *devhdr);
  728.  
  729.                These functions set up and handle DOS critical errors by
  730.           blowing open a window in the screen and providing A)bort, R)etry
  731.           and I)gnore error responses (Notice Abort doesn't abort the
  732.           program but merely returns the error to the function call).  To
  733.           begin critical error processing, call set_critical_error() and
  734.           the rest will be handled by Int 24h calls from DOS.   The color
  735.           of the box is set by the variable __error_color which is by
  736.           default set to intense white on red.
  737.  
  738.           These functions are not available under OS/2.
  739.  
  740.  
  741.  
  742.  
  743.  
  744.  
  745.  
  746.  
  747.  
  748.  
  749.  
  750.  
  751.               ---------------------------------------------------------
  752.                           Data Acquisition Functions Library                          Data Acquisition Functions Library
  753.                                        Page 12                                       Page 12
  754.  
  755.  
  756.  
  757.  
  758.  
  759.           4.4-Keyboard Functions          4.4-Keyboard Functions
  760.           _________________________________________________________________
  761.  
  762.  
  763.           * int read_keyboard(int clock_flag,
  764.                               int clock_pos,
  765.                               int clock_color);
  766.  
  767.                This function returns a keystroke from the keyboard mapped
  768.           into an int.  Normal characters are zero in the high byte and an
  769.           ascii value in the low byte, but extended keystrokes contain a 1
  770.           in the high byte and the scan code in the low.  Screen blanking
  771.           is set for 60 seconds but can be changed by setting the
  772.           __screen_blank_time variable to any number of seconds.  A value
  773.           of 0 indicates no blanking is to be done.  If the clock_flag is
  774.           on, the display of the clock will be of the form:
  775.  
  776.                [ MM/DD/YYYY CN|^A HH:MM:SS ]
  777.  
  778.           where C (Caps lock), N (Number lock), | (Shift), ^ (Ctrl), and A
  779.           (Alt) are keyboard status flags.
  780.  
  781.                If jump is set on (see set_jump_on()), after the determined
  782.           amount of time, longjmp() is executed to the previously prepared
  783.           setjmp() location.
  784.  
  785.  
  786.  
  787.           * extern void far update_time(int clock_pos,
  788.                                         int clock_color);
  789.  
  790.                This function serves to update the clock and keyboard status
  791.           indicators during long periods of activity other than waiting for
  792.           keyboard input and thus avoid moments wherin the clock appears to
  793.           have stopped working.
  794.  
  795.           Example:  See example for open_message() function.
  796.  
  797.  
  798.  
  799.           * void set_jump_off(void);
  800.           * void set_jump_on(int total_time,
  801.                              jmp_buf jump_buffer);
  802.  
  803.                These functions set the system to execute a longjmp() to the
  804.           previously set location (using setjmp()) after total_time seconds
  805.           of keyboard inactivity.  It is meant for systems which need to
  806.           automatically log a person off after a certain amount of time.
  807.           By default, of course the system is set to not jump.
  808.  
  809.  
  810.  
  811.  
  812.  
  813.  
  814.  
  815.  
  816.               ---------------------------------------------------------
  817.                           Data Acquisition Functions Library                          Data Acquisition Functions Library
  818.                                        Page 13                                       Page 13
  819.  
  820.  
  821.  
  822.  
  823.  
  824.           * void disable_boot(void);
  825.           * void enable_boot(void);
  826.  
  827.                The disable_boot() function will disable the Ctrl-Alt-Del
  828.           warm boot capability of the computer temporarily.  The
  829.           enable_boot() function restores everything to normal.
  830.  
  831.           NOTICE:  Under no condition should a program exit without calling
  832.           enable_boot() or else the machine would be in a highly unstable
  833.           state and will eventually crash!  This is an application which
  834.           demands the use of the standard atexit() or onexit() functions.
  835.  
  836.           These functions is not available in OS/2.
  837.  
  838.  
  839.           * int register_key(int key,
  840.                              int (far *handler)(int key,
  841.                                                 int clock_flag,
  842.                                                 int clock_pos,
  843.                                                 int clock_color));
  844.  
  845.           This function sets a default function to occur upon receipt of
  846.           the specified keystroke (key is as defined in keys.h).  The
  847.           handler is a pointer to the function which must return 1 if the
  848.           keystroke must be passed along to the program after its action is
  849.           complete, or return 0 to make the keystroke handler "eat" the
  850.           keystroke and wait for the next key.  *WARNING*  The function
  851.           must either guard against or handle reentrancy if it calls the
  852.           read_keyboard() function.
  853.  
  854.  
  855.           * void deregister_key(int key);
  856.  
  857.                This function removes the specified key from the default-
  858.           handling queue and restores normal meaning to the keystroke.
  859.  
  860.  
  861.           * int (far *query_key(int key))();
  862.  
  863.                This function returns a pointer to the default function
  864.           registered for the specified key or NULL if none is registered.
  865.  
  866.  
  867.  
  868.  
  869.  
  870.  
  871.  
  872.  
  873.  
  874.  
  875.  
  876.  
  877.  
  878.  
  879.  
  880.  
  881.               ---------------------------------------------------------
  882.                           Data Acquisition Functions Library                          Data Acquisition Functions Library
  883.                                        Page 14                                       Page 14
  884.  
  885.  
  886.  
  887.  
  888.  
  889.           4.5-Help Functions          4.5-Help Functions
  890.           _________________________________________________________________
  891.  
  892.  
  893.           * int open_help(char *pathname,int hicolor,int locolor);
  894.  
  895.                This function opens the help file given in pathname and
  896.           assigns the FILE * to helpfd.  This function returns non-zero if
  897.           an error occurs or 0 if it is successful.  The help colors are
  898.           set to the specified colors.  The helpfile must have been created
  899.           with HELPGEN (v 2.00 or greater) and may contain "hot links" to
  900.           other help pages.  For more information on HELPGEN, see the
  901.           chapter "Using Helpgen."
  902.  
  903.  
  904.           * void close_help(void);
  905.  
  906.                This function closes the help system's file and deallocates
  907.           memory used for saving link information.  This function must be
  908.           called before opening a new help system.
  909.  
  910.  
  911.           * void set_help_colors(int hicolor,int locolor);
  912.  
  913.                This function changes the default help colors set by
  914.           open_help() to the new colors specified.
  915.  
  916.  
  917.           * int set_help_key(int key);
  918.  
  919.                This function changes the default help key (originally F1)
  920.           to the key code passed.  It returns the previous keycode.
  921.  
  922.  
  923.           * void set_help_colors(int hicolor,int locolor);
  924.  
  925.                This function changes the default help colors set by
  926.           open_help() to the new colors specified.
  927.  
  928.  
  929.  
  930.  
  931.  
  932.  
  933.  
  934.  
  935.  
  936.  
  937.  
  938.  
  939.  
  940.  
  941.  
  942.  
  943.  
  944.  
  945.  
  946.               ---------------------------------------------------------
  947.                           Data Acquisition Functions Library                          Data Acquisition Functions Library
  948.                                        Page 15                                       Page 15
  949.  
  950.  
  951.  
  952.  
  953.  
  954.           * void register_help(char *help_topic);
  955.           * void deregister_help(void);
  956.           * const char *query_help_topic(void);
  957.  
  958.                These functions allow you to set what help appears on the
  959.           screen when the help key is pressed.  register_help() registers
  960.           the page tagname of the help to be active (i.e. the %page% name
  961.           in the help source file).  deregister_help() removes any help
  962.           topic.  query_help_topic() returns a pointer to the current help
  963.           topic and this may be saved to be replaced later.  If the string
  964.           length of the help topic is 0, there is no topic registered.
  965.  
  966.           Example:  char old_topic[41];
  967.  
  968.                     strcpy(old_help,query_help_topic());
  969.                     register_help("Using Macros");
  970.                     ...
  971.                     register_help(old_help);
  972.  
  973.  
  974.  
  975.           4.6-Sound Functions          4.6-Sound Functions
  976.           _________________________________________________________________
  977.  
  978.  
  979.           * void sound(int tone,int duration);
  980.           * void beep(void);
  981.  
  982.                These functions should be self-explanatory.  The tone value
  983.           is in Hz, and the duration is measured approximately in
  984.           milliseconds.
  985.  
  986.  
  987.  
  988.  
  989.  
  990.  
  991.  
  992.  
  993.  
  994.  
  995.  
  996.  
  997.  
  998.  
  999.  
  1000.  
  1001.  
  1002.  
  1003.  
  1004.  
  1005.  
  1006.  
  1007.  
  1008.  
  1009.  
  1010.  
  1011.               ---------------------------------------------------------
  1012.                           Data Acquisition Functions Library                          Data Acquisition Functions Library
  1013.                                        Page 16                                       Page 16
  1014.  
  1015.  
  1016.  
  1017.  
  1018.           _________________________________________________________________
  1019.  
  1020.                                       Chapter 5                                      Chapter 5
  1021.  
  1022.                                      Keystrokes                                     Keystrokes
  1023.           _________________________________________________________________
  1024.  
  1025.  
  1026.                The following are reserved keystrokes by the editing
  1027.           functions and must not be used by any user functions
  1028.           (specifically in the user function of edit_field):
  1029.  
  1030.                Esc or Alt-Q   -  Abort edit returning E_QUIT
  1031.                Enter          -  Save current edit returning E_EXIT
  1032.                C-End or Alt-X -  Abort edit returning E_END (save)
  1033.                Tab            -  Abort edit returning E_FORE (next)
  1034.                S-Tab          -  Abort edit returning E_BACK (prev)
  1035.                PgUp           -  Abort edit returning E_PGUP
  1036.                PgDn           -  Abort edit returning E_PGDN
  1037.                C-PgUp         -  Page up on select_menu()
  1038.                C-PgDn         -  Page down on select_menu()
  1039.                Alt-C          -  Clear field
  1040.                LeftArrow      -  Move left one space
  1041.                RightArrow     -  Move right one space
  1042.                C-LeftArrow    -  Go to start of field
  1043.                C-RightArrow   -  Go to end of edited string
  1044.                Backspace      -  Delete character left of cursor
  1045.                Delete         -  Delete character under cursor
  1046.                Insert         -  Toggle insert mode on or off
  1047.  
  1048.                It should be obvious that some of these keys are meaningless
  1049.           in pop_menu() and select_menu()!
  1050.  
  1051.  
  1052.  
  1053.  
  1054.  
  1055.  
  1056.  
  1057.  
  1058.  
  1059.  
  1060.  
  1061.  
  1062.  
  1063.  
  1064.  
  1065.  
  1066.  
  1067.  
  1068.  
  1069.  
  1070.  
  1071.  
  1072.  
  1073.  
  1074.  
  1075.  
  1076.               ---------------------------------------------------------
  1077.                           Data Acquisition Functions Library                          Data Acquisition Functions Library
  1078.                                        Page 17                                       Page 17
  1079.  
  1080.  
  1081.  
  1082.  
  1083.           _________________________________________________________________
  1084.  
  1085.                                       Chapter 6                                      Chapter 6
  1086.  
  1087.                                     Using Helpgen                                    Using Helpgen
  1088.           _________________________________________________________________
  1089.  
  1090.  
  1091.                Helpgen is the help file compiler for use with the help
  1092.           functions in this library.  Helpgen is a bound application, which
  1093.           means that it works equally well under DOS or OS/2.  Helpgen
  1094.           expects a flat-ASCII textfile (no embedded control characters)
  1095.           and will compile it to a file with the same base name as the file
  1096.           but with the extension .HLP.  In order to demarcate certain parts
  1097.           of the help source file, there are special keywords.  These are:
  1098.  
  1099.           %title%  - used to set a title for the help system, or for the
  1100.                      specific help page.
  1101.           %width%  - reserved.  The width is fixed at 74 columns.
  1102.           %height% - reserved.  The height is fixed at 21 lines.
  1103.           %page%   - Starts a new help page and labels it with a label for
  1104.                      hypertext jumps.
  1105.           %rem%    - indicates line is a comment line.
  1106.           %center% - indicates line must be centered.
  1107.           %        - used to indicate "hot links" as shown below.
  1108.  
  1109.  
  1110.           Here is a sample help file:
  1111.  
  1112.           %rem% This is a sample file using the HELPGEN system
  1113.           %rem%
  1114.           %rem% First of all a global title.  Used if local titles are not
  1115.           %rem%   defined -->
  1116.           %title% Sample Help File
  1117.  
  1118.           %rem% Now for the first page.  Page titles are limited to 40
  1119.           %rem%   characters.  These are used by "hot links" and by the
  1120.           %rem%   register_help() function -->
  1121.           %page% first page
  1122.  
  1123.  
  1124.           %center%This is the FIRST page of the help system.
  1125.  
  1126.  
  1127.           This can be used to jump to the %SECOND%second page% page or even
  1128.           to the %THIRD%third page% page of the system.  You may use the
  1129.           arrow keys or tab to highlight the appropriate jump or just page
  1130.           sequentially through the help using the PgUp and PgDn keys!
  1131.           %page% second page
  1132.           %rem% This time we will use a local title -->
  1133.           %title% The Second Page
  1134.  
  1135.           %center%This is the SECOND page of the help system.
  1136.  
  1137.  
  1138.  
  1139.  
  1140.  
  1141.               ---------------------------------------------------------
  1142.                           Data Acquisition Functions Library                          Data Acquisition Functions Library
  1143.                                        Page 18                                       Page 18
  1144.  
  1145.  
  1146.  
  1147.  
  1148.  
  1149.           %center%%Go back to the FIRST page%first page%
  1150.           %center%%Go to the THIRD page%third page%
  1151.           %page% third page
  1152.  
  1153.           %center%This is the THIRD and LAST page of the help system.
  1154.  
  1155.  
  1156.           %center%%Go back to the FIRST page%first page%
  1157.           %center%%Go back to the SECOND page%second page%
  1158.  
  1159.           --------
  1160.  
  1161.           As you can see, the hot links are made by using the term to be
  1162.           highlighted in the first pair of % symbols followed by the page
  1163.           name to jump to (e.g. % Term to be Highlighted % page name %).
  1164.  
  1165.  
  1166.  
  1167.  
  1168.  
  1169.  
  1170.  
  1171.  
  1172.  
  1173.  
  1174.  
  1175.  
  1176.  
  1177.  
  1178.  
  1179.  
  1180.  
  1181.  
  1182.  
  1183.  
  1184.  
  1185.  
  1186.  
  1187.  
  1188.  
  1189.  
  1190.  
  1191.  
  1192.  
  1193.  
  1194.  
  1195.  
  1196.  
  1197.  
  1198.  
  1199.  
  1200.  
  1201.  
  1202.  
  1203.  
  1204.  
  1205.  
  1206.               ---------------------------------------------------------
  1207.                           Data Acquisition Functions Library                          Data Acquisition Functions Library
  1208.                                        Page 19                                       Page 19
  1209.  
  1210.  
  1211.  
  1212.  
  1213.  
  1214.                                     Contents                                    Contents
  1215.  
  1216.  
  1217.  
  1218.                Chapter 1  Introduction                               2
  1219.  
  1220.                Chapter 2  Structures and Macros                      3
  1221.  
  1222.                Chapter 3  Field Editing Formats                      4
  1223.                   3.1  Format Types  . . . . . . . . . . . . . . . . 4
  1224.                      3.1.1  Overriding Formats . . . . . . . . . . . 4
  1225.                      3.1.2  Format Modifiers . . . . . . . . . . . . 4
  1226.                      3.1.3  Extended Format Modifiers  . . . . . . . 4
  1227.                      3.1.4  Using Format Strings . . . . . . . . . . 5
  1228.                      3.1.5  Rules for Format Strings . . . . . . . . 5
  1229.                   3.2  User Defined Function for Editor  . . . . . . 6
  1230.  
  1231.                Chapter 4  Functions                                  7
  1232.                   4.1  Field Editing Functions . . . . . . . . . . . 7
  1233.                   4.2  Special Screen Functions  . . . . . . . . .  11
  1234.                   4.3  Error Handling Functions  . . . . . . . . .  12
  1235.                   4.4  Keyboard Functions  . . . . . . . . . . . .  13
  1236.                   4.5  Help Functions  . . . . . . . . . . . . . .  15
  1237.                   4.6  Sound Functions . . . . . . . . . . . . . .  16
  1238.  
  1239.                Chapter 5  Keystrokes                                17
  1240.  
  1241.                Chapter 6  Using Helpgen                             18
  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.                                           i
  1272.