home *** CD-ROM | disk | FTP | other *** search
/ Games 1995 to 2000 / Games.iso / SexTetris / DISPLAY.C < prev    next >
Encoding:
C/C++ Source or Header  |  1993-09-16  |  25.7 KB  |  843 lines

  1. #include "microlib.h"
  2.  
  3. /*****************************************************************************/
  4. /* Function: void statline(char *line)                                       */
  5. /* Description: Displays the status line at row 23 centred. Letters between  */
  6. /*              two "&....&" are printed with the attribute custom[STAT_F].  */
  7. /* Parameters: char *line -> string to display.                              */
  8. /* Returns: Nothing.                                                         */
  9. /* Uses: Attribute from custom[STAT_N] and custom[STAT_F].                   */
  10. /*****************************************************************************/
  11. void statline(line)
  12. char *line;
  13. {
  14.     int i, count, col, intensity_flag, prev_wref;
  15.  
  16.     count = 0;
  17.     i = 0;
  18.     col = 0;
  19.     intensity_flag = 0; /* ( 0=STAT_N, 1=STAT_F ) */
  20.     prev_wref = w4select(1);
  21.  
  22.     strcpy(statusline_save, line);
  23.  
  24.     w4num_att(23, 0, space(80), 80, custom[STAT_N]);
  25.  
  26.     /* Count the '&' characters in line */
  27.     while(line[i]) {
  28.         if(line[i] == '&')
  29.             count ++;
  30.         i ++;
  31.         }
  32.  
  33.     /* Find where the first character will be printed. */
  34.     col = (80 - (strlen(line) - count)) / 2;
  35.  
  36.     /* Print the string in row 23 with the right attributes. */
  37.     i = 0;
  38.     while(line[i]) {
  39.         if(line[i] == '&') {
  40.             intensity_flag = intensity_flag ? 0 : 1 ;
  41.             }
  42.         else {
  43.             w4num_att(23, col, &line[i], 1, intensity_flag ? custom[STAT_F]:custom[STAT_N]);
  44.             col ++;
  45.             }
  46.         i ++;
  47.         }
  48.     w4select(prev_wref);
  49.     }
  50.  
  51. /*****************************************************************************/
  52. /* Function: void helpline(char *line)                                       */
  53. /* Description: Displays the help line at row 24 centred.                    */
  54. /* Parameters: char *line -> string to display.                              */
  55. /* Returns: Nothing.                                                         */
  56. /* Uses: Attribute from custom[MESS_N].                                      */
  57. /*****************************************************************************/
  58. void helpline(line)
  59. char *line;
  60. {
  61.     int col = 0;
  62.     int prev_wref = 0;
  63.  
  64.     prev_wref = w4select(1);
  65.  
  66.     strcpy(helpline_save, line);
  67.     w4num_att(24, 0, space(80), 80, custom[MESS_N]);
  68.     col = (80 - strlen(line))/  2;
  69.     w4num_att(24, col, line, strlen(line), custom[MESS_N]);
  70.     w4select(prev_wref);
  71. }
  72.  
  73. /*****************************************************************************/
  74. /* Function: char *space(int num)                                            */
  75. /* Description: Returns a pointer to a blank string of                       */
  76. /*              num spaces (space_line)                                      */
  77. /* Parameters: int num -> number of spaces.                                  */
  78. /* Returns: A pointer to the string of spaces.                               */
  79. /* Uses: Nothing.                                                            */
  80. /*****************************************************************************/
  81. char *space(num)
  82. int    num;
  83. {
  84.     char *sp_str_p;
  85.     sp_str_p = &space_line[0];
  86.     return(sp_str_p + (80 - num));
  87.     }
  88.  
  89. /*****************************************************************************/
  90. /* Function: blank(char *str, int len)                                                */
  91. /* Description: Fills a sting with spaces.                                   */
  92. /* Parameters: char *str -> String to fill.                                  */
  93. /*             int    len -> Length of string to blank.                       */
  94. /* Returns: Nothing.                                                         */
  95. /* Uses: Nothing.                                                            */
  96. /*****************************************************************************/
  97. int blank(str, len)
  98. char *str;
  99. int len;
  100. {
  101.     int i;
  102.     for (i = 0; i < len; ++ i, str ++)
  103.         *str = ' ';
  104.     }
  105.  
  106.  
  107. /*****************************************************************************/
  108. /* Function: int screen_file(char *scr_filename, int rows, int columns)      */
  109. /* Description: Reads a screen from a file and displays it at the current    */
  110. /*              window.                                                      */
  111. /* Parameters: char *scr_filename -> File name of the screen file.           */
  112. /*             int rows           -> Rows to read and display.               */
  113. /*             int columns        -> Columns to display.                     */
  114. /* Returns: 1 on error, 0 if ok.                                             */
  115. /* Uses: w4display().                                                        */
  116. /*****************************************************************************/
  117. int screen_file(scr_filename, rows, columns)
  118. char *scr_filename;
  119. int rows;
  120. int columns;
  121. {
  122.     FILE *scr;
  123.     int count;
  124.     char line[80];
  125.     char *p_end;   /* Pointer to the newline character. w4() must not    */
  126.                         /* display newline character.                         */
  127.     char *p_input; /* Pointer to the characters '&' in every line.       */
  128.  
  129.  
  130.     char *xorscr;  /* XOR screen pointer                                 */
  131.     int  xc;            /* XOR screen character count                         */
  132.     int  lc;            /* Line count                                         */
  133.     int  xlen;     /* XOR screen actual number of characters. (MAX 2000) */
  134.  
  135.  
  136.     w4clear(0);
  137.     /*  Allocate memory for the XORED screen                        */
  138.     if( (xorscr = (char *) malloc(sizeof(char) * 2000)) == NULL ) {
  139.         w4display(mes[MT], mes[ME+1], (char *) 0);
  140.         w4exit(1);
  141.         }
  142.  
  143.     /* Open the XORED screen file read MAX 2000 characters and close again. */
  144.     if ((scr = fopen(scr_filename, "rb")) == NULL) {
  145.         w4display(mes[MT+1], mes[ME], " ",scr_filename, (char *) 0);
  146.         return(1);
  147.         }
  148.  
  149.     xlen = fread(xorscr, 1, 2000, scr);
  150.     fclose(scr);
  151.  
  152.     xc = 0; /* Point to the first character on the XORED screen (only ONCE!)*/
  153.  
  154.     for(count = 0; count <= rows; count++) {
  155.         /* Simulate fgets() but with a XORED file. */
  156.         for(lc = 0;;xc++, lc++) {
  157.             if(xc == 0)
  158.                 line[lc] = xorscr[xc] ^ 35;
  159.             else
  160.                 line[lc] = xorscr[xc] ^ xorscr[xc-1];
  161.  
  162.             if(line[lc] == '\r') {
  163.                 line[lc]   = '\n';
  164.                 line[lc+1] = '\0';
  165.                 xc ++;
  166.                 xc ++;
  167.                 break;
  168.                 }
  169.             if(lc == columns - 1 || xc >= xlen) {
  170.                 line[lc]   = '\n';
  171.                 line[lc+1] = '\0';
  172.                 xc ++;
  173.                 break;
  174.                 }
  175.             }
  176.  
  177.         p_end = strchr(line, '\n');
  178.         *p_end = ' ';
  179.  
  180.         while((p_input = strchr(line, '&')) != NULL ) {
  181.             *p_input = ' ';
  182.             *(++ p_input) = ' ';
  183.             *(++ p_input) = ' ';
  184.             }
  185.  
  186.         w4(count, 0, line );
  187.         }
  188.  
  189.     free(xorscr);
  190.     return(0);
  191. }
  192.  
  193.  
  194. /*****************************************************************************/
  195. /* Function: int get_input_positions(char *scr_filename)                     */
  196. /* Description: Reads a the input positions from a file and places marks     */
  197. /*              to a mattrix of integers.                                    */
  198. /* Parameters: char *scr_filename -> File name of the screen file.           */
  199. /* Returns: 1 on error, 0 if ok.                                             */
  200. /* Uses: w4display().                                                        */
  201. /*****************************************************************************/
  202. int get_input_positions(scr_filename)
  203. char *scr_filename;
  204. {
  205.     FILE *scr;
  206.     int mark;
  207.     int row;
  208.     int col;
  209.     char line[80];
  210.     char *line_inp; /* Position of marker in line. */
  211.  
  212.     char *xorscr;  /* XOR screen pointer                                 */
  213.     int  xc;            /* XOR screen character count                         */
  214.     int  lc;            /* Line count                                         */
  215.     int  xlen;     /* XOR screen actual number of characters. (MAX 2000) */
  216.  
  217.     /*  Allocate memory for the XORED screen                        */
  218.     if( (xorscr = (char *) malloc(sizeof(char) * 2000)) == NULL ) {
  219.         w4display(mes[MT], mes[ME+1], (char *) 0);
  220.         w4exit(1);
  221.         }
  222.  
  223.     /* Open the XORED screen file read MAX 2000 characters and close again. */
  224.     if ((scr = fopen(scr_filename, "rb")) == NULL) {
  225.         w4display(mes[MT+1], mes[ME], " ",scr_filename, (char *) 0);
  226.         return(1);
  227.         }
  228.     xlen = fread(xorscr, 1, 2000, scr);
  229.     fclose(scr);
  230.  
  231.     /* Mattrix Initialization. */
  232.     for(row = 0; row <= 39; row ++)
  233.         srow[row] = 0;
  234.     for(col = 0; col <= 39; col++ )
  235.         scol[col] = 0;
  236.  
  237.     xc = 0; /* Point to the first character on the XORED screen (only ONCE!)*/
  238.     /* Fill the mattrix. */
  239.     for(row = 0; row <= 24; row++) {
  240.         /* Simulate fgets() but with a XORED file. */
  241.         for(lc = 0;;xc++, lc++) {
  242.             if(xc == 0)
  243.                 line[lc] = xorscr[xc] ^ 35;
  244.             else
  245.                 line[lc] = xorscr[xc] ^ xorscr[xc-1];
  246.  
  247.             if(line[lc] == '\r') {
  248.                 line[lc]   = '\n';
  249.                 line[lc+1] = '\0';
  250.                 xc ++;
  251.                 xc ++;
  252.                 break;
  253.                 }
  254.             if(lc == 79 - 1 || xc >= xlen) {
  255.                 line[lc]   = '\n';
  256.                 line[lc+1] = '\0';
  257.                 xc ++;
  258.                 break;
  259.                 }
  260.             }
  261.  
  262.         while( (line_inp = strchr(line, '&')) != NULL ) {
  263.             *line_inp = ' ';
  264.             line_inp[3] = '\0';
  265.             col = line_inp - line;
  266.             srow[atoi(line_inp)] = row;
  267.             scol[atoi(line_inp)] = col + 1;
  268.             line_inp[3] = ' ';
  269.             }
  270.         }
  271.     free(xorscr);
  272.     return(0);
  273. }
  274.  
  275.  
  276. /*****************************************************************************/
  277. /* Function: int zerofill(char *field, int num)                              */
  278. /* Description: Fills with zeros the begining of a field which is not        */
  279. /*              filled from the user.                                        */
  280. /* Parameters: char *field -> File name of the screen file.                  */
  281. /*             int num     -> The Width of the field.                        */
  282. /* Returns: Nothing.                                                         */
  283. /* Uses: Nothing.                                                            */
  284. /*****************************************************************************/
  285. int zerofill(field, num)
  286. char *field;
  287. int num;
  288. {
  289.     int count, i;
  290.     char tmp_field[20];
  291.  
  292.     memcpy(tmp_field, field, num);
  293.  
  294.     c4trim_n(tmp_field, num+1);
  295.     for(count = 0; count < num - strlen(tmp_field); count ++)
  296.         field[count] = '0';
  297.  
  298.     i = 0;
  299.     while(count < num) {
  300.         field[count] = tmp_field[i ++];
  301.         count ++;
  302.         }
  303.     }
  304.  
  305. /*****************************************************************************/
  306. /* Function: int wshow(char *line)                                           */
  307. /* Description: Displays a window with a string.                             */
  308. /* Parameters: char *line -> string to display.                              */
  309. /* Returns: TRUE if ENTER, FALSE if ESC                                      */
  310. /* Uses:                                                                     */
  311. /*****************************************************************************/
  312. int wshow(line)
  313. char *line;
  314. {
  315.     int wshow_wref;
  316.  
  317.     wshow_wref = w4define(10, 15, 16, 65);
  318.     w4border( DOUBLE, custom[WAIT_B]);
  319.     w4attribute (custom[WAIT_N]);
  320.     w4popup();
  321.     w4memory();
  322.     w4activate(wshow_wref);
  323.  
  324.     w4centre(1, line);
  325.     return(0);
  326.     }
  327.  
  328. /*****************************************************************************/
  329. /* Function: int warning(char *line)                                         */
  330. /* Description: Displays a warrning window and waits for Esc or Enter.       */
  331. /* Parameters: char *line -> string to display.                              */
  332. /* Returns: TRUE if ENTER, FALSE if ESC                                      */
  333. /* Uses:                                                                     */
  334. /*****************************************************************************/
  335. int warning(line)
  336. char *line;
  337. {
  338.     int col = 0;
  339.     int warn_wref;
  340.     int key_val;
  341.  
  342.     warn_wref = w4define(10, 15, 16, 65);
  343.     w4border( DOUBLE, custom[WARN_N]);
  344.     w4attribute (custom[WARN_N]);
  345.     w4popup();
  346.     w4memory();
  347.     w4activate(warn_wref);
  348.  
  349.     col = (50 - strlen(line))/  2;
  350.     w4(1, col, line);
  351.     w4(2, 14, "ENTER-NAI / ESC-OXI");
  352.     w4(2, 43, "┌───┐");
  353.     w4(3, 43, "│ ! │");
  354.     w4(4, 43, "└───┘");
  355.     for(;;) {
  356.         key_val = g4char();
  357.         if(key_val == RETURN ) {
  358.             w4deactivate(warn_wref);
  359.             w4close(warn_wref);
  360.             w4select(warn_wref -1);
  361.             return(1);
  362.             }
  363.         if(key_val == ESC) {
  364.             w4deactivate(warn_wref);
  365.             w4close(warn_wref);
  366.             w4select(warn_wref -1);
  367.             return(0);
  368.             }
  369.         }
  370.     }
  371.  
  372. /*****************************************************************************/
  373. /* Function: int help(char *search_str)                                      */
  374. /* Description: Displays the help screen with the index key "search_key".    */
  375. /* Parameters: char *search_str -> index key to search for.                  */
  376. /* Returns: Nothing.                                                         */
  377. /* Uses:                                                                     */
  378. /*****************************************************************************/
  379. #define    NEXTSYMBOL    "\20"
  380. int help(search_str)
  381. char *search_str;
  382. {
  383.     FILE    *hlp;
  384.     int    help_wref;
  385.     int    previous_wref;
  386.     int    no_help_flag;        /* Flag: If TRUE the Index Key was not found. */
  387.  
  388.     int    cur_row;
  389.     char    line[80];
  390.     char    *lpos;                /* Pointer to the line string. (Used to convert */
  391.                                     /* '\n' to NULL                                            */
  392.     char *ind;
  393.     int i;
  394.     long file_pos;
  395.  
  396.     no_help_flag = FALSE;
  397.     cur_row = 1;
  398.     line[0]='\0';
  399.     previous_wref = w4select(-1);
  400.  
  401.     help_wref = w4define(3, 3, 21, 76);
  402.     w4border(DOUBLE, custom[HELPSCR_N]);
  403.     w4attribute(custom[HELPSCR_N]);
  404.     w4popup();
  405.     w4memory();
  406.     w4activate(help_wref);
  407.     /* Open help file.                                    */
  408.     if ((hlp = fopen("IEP.HLP", "rb")) == NULL) {
  409.         w4display("", mes[ME], "IEP.HLP", (char *)0);
  410.         w4deactivate(help_wref);
  411.         w4close(help_wref);
  412.         w4select(previous_wref);
  413.         return(1);
  414.         }
  415.  
  416.     /*  Allocate memory for the XORED index                        */
  417.     if( (ind = (char *) malloc(sizeof(char) * 2000)) == NULL ) {
  418.         w4display(mes[MT], mes[ME+1], (char *) 0);
  419.         w4exit(1);
  420.         }
  421.  
  422.     /* Seek for Index Key !                         */
  423.     fread(ind, 1, 2000, hlp);
  424.     for(i = 0; i <= 1999; i++) {
  425.         ind[i] = ind[i] ^ 35;
  426.         }
  427.  
  428.     if(!strstr(ind, search_str)) {
  429.         w4display("", mes[ME+8], (char *)0);
  430.         no_help_flag = TRUE;
  431.         }
  432.     if( ! no_help_flag) {
  433.         /* If found display title.         */
  434.         w4attribute(custom[HELPSCR_T]);
  435.         file_pos = c4atol(strstr(ind, search_str) + 20, 6);
  436.         fseek(hlp, file_pos, SEEK_SET);
  437.  
  438.         xorgets(line, 79, hlp);
  439.         lpos = strchr(line, '\n');
  440.         *lpos = '\0';
  441.         w4(cur_row, 1, line);
  442.  
  443.         /* Display help.                         */
  444.         w4attribute(custom[HELPSCR_N]);
  445.         xorgets(line, 79, hlp);
  446.         cur_row ++;
  447.         for(;;) {
  448.             for(;cur_row <= 15; cur_row ++) {
  449.                 lpos = strchr(line, '\n');
  450.                 *lpos = '\0';
  451.                 w4(cur_row, 1, line);
  452.                 xorgets(line, 79, hlp);
  453.                 if( strstr(line, "##")) {
  454.                     break;
  455.                     }
  456.                 }
  457.             if( strstr(line, "##")) {
  458.                 g4char();
  459.                 break;
  460.                 }
  461.             w4num_att(16, 69, NEXTSYMBOL, 1, custom[HELPSCR_S]);
  462.             if(g4char() == ESC)
  463.                 break;
  464.             w4clear(0);
  465.             cur_row = 1;
  466.             }
  467.         }
  468.     free(ind);
  469.     fclose(hlp);
  470.     w4deactivate(help_wref);
  471.     w4close(help_wref);
  472.     w4select(previous_wref);
  473.     }
  474.  
  475. int xorgets(char *line, int num, FILE *fp)
  476. {
  477.     char *xorline;
  478.  
  479.     int  lc;            /* Line count                                         */
  480.     int  xc;            /* Line count                                         */
  481.     int  xlen ;
  482.     long file_pos;
  483.  
  484.     /*  Allocate memory for the XORED line                        */
  485.     if( (xorline = (char *) malloc(sizeof(char) * num)) == NULL ) {
  486.         w4display(mes[MT], mes[ME+1], (char *) 0);
  487.         w4exit(1);
  488.         }
  489.  
  490.     file_pos = ftell(fp);
  491.  
  492.     xlen = fread(xorline, 1, num, fp);
  493.     if( !xlen ) {
  494.         free(xorline);
  495.         return(0);
  496.         }
  497.  
  498.     xc = 0;
  499.     for(lc = 0;; lc++) {
  500.         line[lc] = xorline[xc] ^ 35;
  501.         xc ++;
  502.  
  503.         if(line[lc] == '\r') {
  504.             line[lc]   = '\n';
  505.             line[lc+1] = '\0';
  506.             xc ++;
  507.             fseek(fp, file_pos + (long) xc, SEEK_SET);
  508.             break;
  509.             }
  510.         if( lc == num - 1 ) {
  511.             line[lc]   = '\n';
  512.             line[lc+1] = '\0';
  513.             break;
  514.             }
  515.         }  /* for loop */
  516.     free(xorline);
  517.     return(1);
  518.     }
  519.  
  520. #ifdef MANOS
  521. int xorgets(char *line, int num, FILE *fp)
  522. {
  523.     char *xorline;
  524.  
  525.     char xtmp;     /* XOR character                                      */
  526.     int  lc;            /* Line count                                         */
  527.     int  xc;            /* Line count                                         */
  528.     int  xlen ;
  529.     long file_pos;
  530.  
  531.     /*  Allocate memory for the XORED line                        */
  532.     if( (xorline = (char *) malloc(sizeof(char) * num)) == NULL ) {
  533.         w4display(mes[MT], mes[ME+1], (char *) 0);
  534.         w4exit(1);
  535.         }
  536.  
  537.     file_pos = ftell(fp);
  538.     if(file_pos != 0L) {
  539.         fseek(fp, -1L, SEEK_CUR);
  540.         fread(&xtmp, 1, 1, fp);
  541.         }
  542.  
  543.     xlen = fread(xorline, 1, num, fp);
  544.     if( !xlen ) {
  545.         free(xorline);
  546.         return(0);
  547.         }
  548.  
  549.     xc = 0;
  550.     for(lc = 0;; lc++) {
  551.         if(lc == 0 && file_pos == 0L) {
  552.             line[lc] = xorline[xc] ^ 35;
  553.             xtmp     = xorline[xc];
  554.             xc ++;
  555.             }
  556.         else {
  557.             line[lc] = xorline[xc] ^ xtmp;
  558.             xtmp     = xorline[xc];
  559.             xc ++;
  560.             }
  561.  
  562.         if(line[lc] == '\r') {
  563.             line[lc]   = '\n';
  564.             line[lc+1] = '\0';
  565.             xc ++;
  566.             fseek(fp, file_pos + (long) xc, SEEK_SET);
  567.             break;
  568.             }
  569.         if( lc == num - 1 ) {
  570.             line[lc]   = '\n';
  571.             line[lc+1] = '\0';
  572.             break;
  573.             }
  574.         }  /* for loop */
  575.     free(xorline);
  576.     return(1);
  577.     }
  578. #endif
  579.  
  580. /*****************************************************************************/
  581. /* Function: int browse(int wtop, int wleft, int wbottom, char *wtitle,      */
  582. /*                    D4DATA *dbfile, X4FILTER filter, F4FIELD **fields_ref, */
  583. /*                             int num_fields)                                                       */
  584. /* Description: Browses the specified fields of the selected database        */
  585. /* Parameters: int wtop        -                                             */
  586. /*             int wleft       -                                             */
  587. /*             int wbottom     -> Coordinates of the browse window.          */
  588. /*         X4FILTER filter    -> The database to be browsed.                 */
  589. /*         F4FIELD **fields_ref-> Mattrix containing the reference numbers   */
  590. /*                                of the fields to be displayed.             */
  591. /*             int num_fields  -> Total number of fields to be displayed.    */
  592. /* Returns: Nothing.                                                         */
  593. /* Uses: w4define(), w4activate(), w4attribute(), w4num_att(), w4border(),   */
  594. /*       w4title(), w4popup(), w4memory(), w4select(), w4deactivate(),       */
  595. /*       w4close(), f4width(), f4str(), x4skip(), x4bottom().                */
  596. /*****************************************************************************/
  597. int browse(wtop, wleft, wbottom, wtitle, dbfile, filter, fields_ref, num_fields)
  598. int wtop, wleft, wbottom, num_fields;
  599. char *wtitle;
  600. D4DATA *dbfile;
  601. X4FILTER filter;
  602. F4FIELD **fields_ref;
  603. {
  604.     int browse_wref, prev_wref;
  605.     int key_val;
  606.     int i;                /* Counter. */
  607.     int cur_col = 0;
  608.     int cur_row = 0;
  609.     int wright;            /* Window's Right position. */
  610.     int maxrow = (wbottom - wtop) - 2;
  611.     char result_ptr[9];
  612.  
  613.     /* Find window's right border position. */
  614.     for(i = 0, wright = 0; i <= num_fields -1; i ++) {
  615.         wright = wright + f4len(fields_ref[i]);
  616.         ++ wright;
  617.         }
  618.     wright = wleft + wright;
  619.     /* Create the Browse window                   */
  620.     browse_wref = w4define(wtop, wleft, wbottom, wright);
  621.     w4attribute(custom[BROWSER_N]);
  622.     w4border(DOUBLE, custom[BROWSER_B]);
  623.     w4title(0, 1, wtitle,custom[BROWSER_B]);
  624.     w4popup();
  625.     w4memory();
  626.     w4activate(browse_wref);
  627.     prev_wref = w4select(-1) - 1;
  628.  
  629.     /* Display the records */
  630.     for(cur_row = 0; cur_row <= maxrow ; cur_row ++) { /* ==L1== */
  631.         for(i = 0; i < num_fields -1 ; i ++) { /* == L2 == */
  632.             if(f4type(fields_ref[i]) == 'D') {
  633.                 a4format(f4str(fields_ref[i]), result_ptr, "DD/MM/YY");
  634.                 w4num_att(cur_row, cur_col, result_ptr,\
  635.                                  f4len(fields_ref[i]), custom[BROWSER_N]);
  636.                 }
  637.             else
  638.                 w4num_att(cur_row, cur_col, f4str(fields_ref[i]),\
  639.                                      f4len(fields_ref[i]), custom[BROWSER_N]);
  640.             cur_col = cur_col + f4len(fields_ref[i]);
  641.             w4num_att(cur_row, cur_col, "│", 1, custom[BROWSER_N]);
  642.             ++ cur_col;
  643.             } /* == L2 == */
  644.         if(f4type(fields_ref[i]) == 'D') {
  645.             a4format(f4str(fields_ref[i]), result_ptr, "DD/MM/YY");
  646.             w4num_att(cur_row, cur_col, result_ptr,\
  647.                              f4len(fields_ref[i]), custom[BROWSER_N]);
  648.             }
  649.         else
  650.             w4num_att(cur_row, cur_col, f4str(fields_ref[i]),\
  651.                                      f4len(fields_ref[i]), custom[BROWSER_N]);
  652.         if(x4skip( &filter, 1)) {
  653.             d4unlock_index(dbfile);
  654.             break;
  655.             }
  656.         d4unlock_index(dbfile);
  657.         cur_col = 0;
  658.         } /* == L1 == */
  659.  
  660.     /* Skip to the first record found. */
  661.     for(i = 0 ; i <= cur_row; i ++)
  662.         x4skip(&filter, -1);
  663.  
  664.     d4unlock_index(dbfile);
  665.     cur_col = 0;
  666.     cur_row = 0;
  667.  
  668.     /* Display the bar */
  669.     for(i = 0; i < num_fields -1 ; i ++) { /* == L1 == */
  670.         if(f4type(fields_ref[i]) == 'D') {
  671.             a4format(f4str(fields_ref[i]), result_ptr, "DD/MM/YY");
  672.             w4num_att(cur_row, cur_col, result_ptr,\
  673.                              f4len(fields_ref[i]), custom[BROWSER_S]);
  674.             }
  675.         else
  676.             w4num_att(cur_row, cur_col, f4str(fields_ref[i]),\
  677.                                  f4len(fields_ref[i]), custom[BROWSER_S]);
  678.         cur_col = cur_col + f4len(fields_ref[i]);
  679.         w4num_att(cur_row, cur_col, "│", 1, custom[BROWSER_S]);
  680.         ++ cur_col;
  681.         } /* == L1 == */
  682.     if(f4type(fields_ref[i]) == 'D') {
  683.         a4format(f4str(fields_ref[i]), result_ptr, "DD/MM/YY");
  684.         w4num_att(cur_row, cur_col, result_ptr,\
  685.                          f4len(fields_ref[i]), custom[BROWSER_S]);
  686.         }
  687.     else
  688.         w4num_att(cur_row, cur_col, f4str(fields_ref[i]),\
  689.                                  f4len(fields_ref[i]), custom[BROWSER_S]);
  690.     cur_col = 0;
  691.  
  692.  
  693.     for (;;) { /* == L1 == */
  694.         key_val = g4char();
  695.  
  696.         if(key_val == ESC || key_val == RETURN)
  697.             break;
  698.         if(key_val == DOWN) { /* == If DOWN == */
  699.             /* Display with normal attribute the current row. */
  700.             for(i = 0, cur_col = 0; i < num_fields -1 ; i ++) { /* == L2 == */
  701.                 if(f4type(fields_ref[i]) == 'D') {
  702.                     a4format(f4str(fields_ref[i]), result_ptr, "DD/MM/YY");
  703.                     w4num_att(cur_row, cur_col, result_ptr,\
  704.                                      f4len(fields_ref[i]), custom[BROWSER_N]);
  705.                     }
  706.                 else
  707.                     w4num_att(cur_row, cur_col, f4str(fields_ref[i]),\
  708.                                  f4len(fields_ref[i]), custom[BROWSER_N]);
  709.                 cur_col = cur_col + f4len(fields_ref[i]);
  710.                 w4num_att(cur_row, cur_col, "│", 1, custom[BROWSER_N]);
  711.                 ++ cur_col;
  712.                 } /* == L2 == */
  713.             if(f4type(fields_ref[i]) == 'D') {
  714.                 a4format(f4str(fields_ref[i]), result_ptr, "DD/MM/YY");
  715.                 w4num_att(cur_row, cur_col, result_ptr,\
  716.                                  f4len(fields_ref[i]), custom[BROWSER_N]);
  717.                 }
  718.             else
  719.                 w4num_att(cur_row, cur_col, f4str(fields_ref[i]),\
  720.                                  f4len(fields_ref[i]), custom[BROWSER_N]);
  721.  
  722.             if (x4skip(&filter, 1) == r4eof) {
  723.                 x4bottom(&filter);
  724.                 cur_row --;
  725.                 }
  726.             d4unlock_index(dbfile);
  727.             if (cur_row == maxrow) {
  728.                 cur_row --;
  729.                 w4scroll(1);
  730.                 }
  731.             cur_row ++;
  732.             /* Display the bar */
  733.             for(i = 0, cur_col = 0; i < num_fields -1 ; i ++) { /* ==L2 ==*/
  734.                 if(f4type(fields_ref[i]) == 'D') {
  735.                     a4format(f4str(fields_ref[i]), result_ptr, "DD/MM/YY");
  736.                     w4num_att(cur_row, cur_col, result_ptr,\
  737.                                      f4len(fields_ref[i]), custom[BROWSER_S]);
  738.                     }
  739.                 else
  740.                     w4num_att(cur_row, cur_col, f4str(fields_ref[i]),\
  741.                                  f4len(fields_ref[i]), custom[BROWSER_S]);
  742.                 cur_col = cur_col + f4len(fields_ref[i]);
  743.                 w4num_att(cur_row, cur_col, "│", 1, custom[BROWSER_S]);
  744.                 ++ cur_col;
  745.                 } /* ==L2==*/
  746.             if(f4type(fields_ref[i]) == 'D') {
  747.                 a4format(f4str(fields_ref[i]), result_ptr, "DD/MM/YY");
  748.                 w4num_att(cur_row, cur_col, result_ptr,\
  749.                                  f4len(fields_ref[i]), custom[BROWSER_S]);
  750.                 }
  751.             else
  752.                 w4num_att(cur_row, cur_col, f4str(fields_ref[i]),\
  753.                                  f4len(fields_ref[i]), custom[BROWSER_S]);
  754.             } /* == If DOWN == */
  755.  
  756.  
  757.         else if (key_val == UP) { /* == If UP == */
  758.             /* Display with normal attribute the current row. */
  759.             for(i = 0, cur_col = 0; i < num_fields -1 ; i ++) { /* == L2 ==*/
  760.                 if(f4type(fields_ref[i]) == 'D') {
  761.                     a4format(f4str(fields_ref[i]), result_ptr, "DD/MM/YY");
  762.                     w4num_att(cur_row, cur_col, result_ptr,\
  763.                                      f4len(fields_ref[i]), custom[BROWSER_N]);
  764.                     }
  765.                 else
  766.                     w4num_att(cur_row, cur_col, f4str(fields_ref[i]),\
  767.                              f4len(fields_ref[i]), custom[BROWSER_N]);
  768.                 cur_col = cur_col + f4len(fields_ref[i]);
  769.                 w4num_att(cur_row, cur_col, "│", 1, custom[BROWSER_N]);
  770.                 ++ cur_col;
  771.                 } /* == L2 == */
  772.             if(f4type(fields_ref[i]) == 'D') {
  773.                 a4format(f4str(fields_ref[i]), result_ptr, "DD/MM/YY");
  774.                 w4num_att(cur_row, cur_col, result_ptr,\
  775.                                  f4len(fields_ref[i]), custom[BROWSER_N]);
  776.                 }
  777.             else
  778.                 w4num_att(cur_row, cur_col, f4str(fields_ref[i]),\
  779.                                  f4len(fields_ref[i]), custom[BROWSER_N]);
  780.             if (x4skip(&filter, -1)) {
  781.                 x4top(&filter);
  782.                 cur_row ++;
  783.                 }
  784.             d4unlock_index(dbfile);
  785.             if (cur_row == 0) {
  786.                 cur_row ++;
  787.                 w4scroll(-1);
  788.                 }
  789.             cur_row --;
  790.             for(i = 0, cur_col = 0; i < num_fields -1 ; i ++) {
  791.                 if(f4type(fields_ref[i]) == 'D') {
  792.                     a4format(f4str(fields_ref[i]), result_ptr, "DD/MM/YY");
  793.                     w4num_att(cur_row, cur_col, result_ptr,\
  794.                                      f4len(fields_ref[i]), custom[BROWSER_S]);
  795.                     }
  796.                 else
  797.                     w4num_att(cur_row, cur_col, f4str(fields_ref[i]),\
  798.                                  f4len(fields_ref[i]), custom[BROWSER_S]);
  799.                 cur_col = cur_col + f4len(fields_ref[i]);
  800.                 w4num_att(cur_row, cur_col, "│", 1, custom[BROWSER_S]);
  801.                 ++ cur_col;
  802.                 }
  803.             if(f4type(fields_ref[i]) == 'D') {
  804.                 a4format(f4str(fields_ref[i]), result_ptr, "DD/MM/YY");
  805.                 w4num_att(cur_row, cur_col, result_ptr,\
  806.                                  f4len(fields_ref[i]), custom[BROWSER_S]);
  807.                 }
  808.             else
  809.                 w4num_att(cur_row, cur_col, f4str(fields_ref[i]),\
  810.                                  f4len(fields_ref[i]), custom[BROWSER_S]);
  811.             } /* == If UP == */
  812.         } /* == L1 == */
  813.     w4deactivate(browse_wref);
  814.     w4close(browse_wref);
  815.     w4select(prev_wref);
  816.     return(key_val);
  817.     }
  818.  
  819. int deb(times)
  820. int times;
  821. {
  822.     int count;
  823.     long i;
  824.  
  825.     for(count = 1; count <= times; count ++) {
  826.         g4bell_set(1);
  827.         g4bell();
  828.         g4bell_set(0);
  829.         for(i = 1 ; i <= 130000; i ++);
  830.         }
  831.     g4char();
  832.     }
  833.  
  834. int clen( entry_area, length )
  835. char *entry_area;
  836. int length;
  837. {
  838.     if(memcmp(entry_area, space(length), length))
  839.         return(length);
  840.     else
  841.         return(0);
  842.     }
  843.