home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / thesrc15.zip / query.c < prev    next >
C/C++ Source or Header  |  1993-11-30  |  88KB  |  2,819 lines

  1. /***********************************************************************/
  2. /* QUERY.C -                                                           */
  3. /* This file contains functions related to QUERY,STATUS and EXTRACT    */
  4. /***********************************************************************/
  5. /*
  6.  * THE - The Hessling Editor. A text editor similar to VM/CMS xedit.
  7.  * Copyright (C) 1991-1993 Mark Hessling
  8.  *
  9.  * This program is free software; you can redistribute it and/or
  10.  * modify it under the terms of the GNU General Public License as
  11.  * published by the Free Software Foundation; either version 2 of
  12.  * the License, or any later version.
  13.  *
  14.  * This program is distributed in the hope that it will be useful,
  15.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17.  * General Public License for more details.
  18.  *
  19.  * You should have received a copy of the GNU General Public License
  20.  * along with this program; if not, write to:
  21.  *
  22.  *    The Free Software Foundation, Inc.
  23.  *    675 Mass Ave,
  24.  *    Cambridge, MA 02139 USA.
  25.  *
  26.  *
  27.  * If you make modifications to this software that you feel increases
  28.  * it usefulness for the rest of the community, please email the
  29.  * changes, enhancements, bug fixes as well as any and all ideas to me.
  30.  * This software is going to be maintained and enhanced as deemed
  31.  * necessary by the community.
  32.  *
  33.  * Mark Hessling                     email: M.Hessling@gu.edu.au
  34.  * 36 David Road                     Phone: +61 7 849 7731
  35.  * Holland Park                      Fax:   +61 7 875 5314
  36.  * QLD 4121
  37.  * Australia
  38.  */
  39.  
  40. /*
  41. $Header: C:\THE\RCS\query.c 1.4 1993/09/01 16:27:03 MH Interim MH $
  42. */
  43.  
  44. #include <stdio.h>
  45.  
  46. #include "the.h"
  47. #include "proto.h"
  48. #include "query.h"
  49.  
  50. #ifdef PROTO
  51. static int extract_pending(int,char *);
  52. static int extract_point(int,char *);
  53. static int extract_prefix(int,char *);
  54. #else
  55. static int extract_pending();
  56. static int extract_point();
  57. static int extract_prefix();
  58. #endif
  59.  
  60. /*man-start*********************************************************************
  61.  
  62.  
  63. ========================================================================
  64. QUERY, EXTRACT and STATUS
  65. ========================================================================
  66.  
  67.      The following lists the valid variables that can be queried and
  68.      also shows what values are returned. For both QUERY and STATUS,
  69.      the values are concatenated together and displayed as a single
  70.      line. For EXTRACT the REXX variables that are set are defined.
  71.      The capitalised portion of the variable is the minimum abbreviation
  72.      recognised.
  73.      The bracketed text at the end of the description indicates from
  74.      which commands a valid response will be supplied (Q-Query,E-Extract
  75.      and S-Status).
  76.  
  77. ALT
  78.      The number of alterations to the current file since the last SAVE
  79.      or AUTOSAVE.
  80.      (QES)
  81.  
  82.      alt.0           - 2
  83.      alt.1           - Number of alterations since last SAVE or AUTOSAVE
  84.      alt.2           - Number of alterations since last SAVE
  85.  
  86. ARBchar
  87.      The status of ARBCHAR and the ARBCHAR character.
  88.      (QES)
  89.  
  90.      arbchar.0       - 2
  91.      arbchar.1       - ON|OFF
  92.      arbchar.2       - ARBCHAR character
  93.  
  94. AUtosave
  95.      The status of AUTOSAVE and/or the frequency setting.
  96.      (QES)
  97.  
  98.      autosave.0      - 1
  99.      autosave.1      - OFF|n
  100.  
  101. BACKup
  102.      Indicates if a .bak file is kept after editing.
  103.      (QES)
  104.  
  105.      backup.0        - 1
  106.      backup.1        - ON|OFF
  107.  
  108. BEEP
  109.      Indicates if the bell is sounded on display of error messages.
  110.      (QES)
  111.  
  112.      beep.0          - 1
  113.      beep.1          - ON|OFF
  114.  
  115. BLOCK
  116.      Returns information about the marked block, if any.
  117.      (E)
  118.  
  119.      block.0         - 6 if a marked block exists, or 1 for NONE
  120.      block.1         - type of marked block (LINE|BOX|NONE)
  121.      block.2         - line number of start of block
  122.      block.3         - column number of start of block
  123.      block.4         - line number of end of block
  124.      block.5         - column number of end of block
  125.      block.6         - file name containing marked block
  126.  
  127. CASE
  128.      The settings related to the CASE of characters entered, searched
  129.      for, changed and sorted.
  130.      (QES)
  131.  
  132.      case.0          - 4
  133.      case.1          - MIXED|UPPER|LOWER
  134.      case.2          - RESPECT|IGNORE
  135.      case.3          - RESPECT|IGNORE
  136.      case.4          - RESPECT|IGNORE
  137.  
  138. CLEARScreen
  139.      Indicates if the screen is cleared on exit from THE.
  140.      (QES)
  141.  
  142.      clearscreen.0   - 1
  143.      clearscreen.1   - ON|OFF
  144.  
  145. CLOCK
  146.      Indicates if the time is displayed on the status line.
  147.      (QES)
  148.  
  149.      clock.0         - 1
  150.      clock.1         - ON|OFF
  151.  
  152. CMDArrows
  153.      Returns the settings for arrow key behaviour.
  154.      (QES)
  155.  
  156.      cmdarrows.0     - 3
  157.      cmdarrows.1     - RETRIEVE|TAB
  158.      cmdarrows.2     - SCROLL|TAB
  159.      cmdarrows.3     - SCROLL|TAB
  160.  
  161. CMDline
  162.      The settings for the command line.
  163.      (QES)
  164.  
  165.      cmdline.0       - 3
  166.      cmdline.1       - TOP|BOTTOM
  167.      cmdline.2 *     - line number within window of command line
  168.      cmdline.3 *     - contents of command line
  169.                * these values are only returned with EXTRACT
  170.  
  171. CURline
  172.      The value and position of the current line within the current file.
  173.      (E)
  174.  
  175.      curline.0       - 3
  176.      curline.1       - -1
  177.      curline.2       - line number within window of current line
  178.      curline.3       - contents of current line
  179.  
  180. DIRFILEID
  181.      The value of the path and filename of the focus line in a DIR.DIR
  182.      file.
  183.      (E)
  184.  
  185.      dirfileid.0     - 2
  186.      dirfileid.1     - full path of directory
  187.      dirfileid.2     - file name at focus line
  188.  
  189. EOF
  190.      Indicates if the current line is on the *** Bottom of file *** line.
  191.      (QES)
  192.  
  193.      eof.0           - 1
  194.      eof.2           - ON|OFF
  195.  
  196. EOLout
  197.      Returns the value of the end-of-line character(s).
  198.      (QES)
  199.  
  200.      eolout.0        - 1
  201.      eolout.1        - LF|CRLF
  202.  
  203. ETMODE
  204.      Indicates if extended display mode is set.
  205.      (QES)
  206.  
  207.      etmode.0        - 1
  208.      etmode.1        - ON|OFF
  209.  
  210. FNAME
  211.      The file name of the current file.
  212.      (E)
  213.  
  214.      fname.0         - 1
  215.      fname.1         - File name.
  216.  
  217. FPATH
  218.      The path name of the current file. This includes a trailing
  219.      directory seperator.
  220.      (E)
  221.  
  222.      fpath.0         - 1
  223.      fpath.1         - File path.
  224.  
  225. FTYPE
  226.      The extension of the current file. The characters following
  227.      the trailing '.' character.
  228.      (E)
  229.  
  230.      ftype.0         - 1
  231.      ftype.1         - File extension.
  232.  
  233. GETENV variable
  234.      The value of the supplied environment variable or ***invalid***
  235.      if the variable does not exist.
  236.      (E)
  237.  
  238.      getenv.0        - 1
  239.      getenv.1        - value of variable
  240.  
  241. HEX
  242.      Indicates if HEX is on or off.
  243.      (QES)
  244.  
  245.      hex.0           - 1
  246.      hex.1           - ON|OFF
  247.  
  248. HEXDISPlay
  249.      Indicates if the current character is displayed on the status line.
  250.      (QES)
  251.  
  252.      hexdisplay.0    - 1
  253.      hexdisplay.1    - ON|OFF
  254.  
  255. IMPMACro
  256.      Indicates if implied macro processing is on or off.
  257.      (QES)
  258.  
  259.      impmacro.0      - 1
  260.      impmacro.1      - ON|OFF
  261.  
  262. IMPOS
  263.      Indicates if implied operating system command processing is on 
  264.      or off.
  265.      (QES)
  266.  
  267.      impos.0         - 1
  268.      impos.1         - ON|OFF
  269.  
  270. INSERTmode
  271.      Indicates if currently in insert mode or overstrike mode.
  272.      (QES)
  273.  
  274.      insertmode.1    - 1
  275.      insertmode.1    - ON|OFF
  276.  
  277. LASTmsg
  278.      Return the text of the last error message generated.
  279.      (E)
  280.  
  281.      lastmsg.0       - 1
  282.      lastmsg.1       - text of last message.
  283.  
  284. LASTRC
  285.      Return code from last command issued from command line.
  286.      (QES)
  287.  
  288.      lastrc.0        - 1
  289.      lastrc.1        - Last return code.
  290.  
  291. LENgth
  292.      Length of the current line.
  293.      (QES)
  294.  
  295.      length.0        - 1
  296.      length.1        - Length of current line.
  297.  
  298. LIne
  299.      Line number of current line in current file.
  300.      (QES)
  301.  
  302.      line.0          - 1
  303.      line.1          - Line number
  304.  
  305. LINENd
  306.      Indicates if multiple commands allowed on command line
  307.      and the delimiter.
  308.      (QES)
  309.  
  310.      linend.0        - 2
  311.      linend.1        - ON|OFF
  312.      linend.2        - delimiter
  313.  
  314. MACROExt
  315.      The current setting for a macro's file extension.
  316.      (QES)
  317.  
  318.      macroext.0      - 1
  319.      macroext.1      - Default file extension
  320.  
  321. MACROPath
  322.      The path that THE looks for by default for macro files.
  323.      (E)
  324.  
  325.      macropath.0     - 1
  326.      macropath.1     - Path for macro files.
  327.  
  328. MARgins
  329.      The settings for left and right margins and paragraph indent.
  330.      (QES)
  331.  
  332.      margins.0       - 3
  333.      margins.1       - left column
  334.      margins.2       - right column
  335.      margins.3       - indent value (column or offset from left margin)
  336.  
  337. MONITOR
  338.      Indicates if the combination of monitor and the curses package
  339.      supports colour. If the curses package supports colour, then
  340.      monitor.3 is set to COLOR and monitor.2 can be COLOR or MONO
  341.      depending on whether the monitor supports colour. If monitor.3
  342.      is MONO then monitor.2 will also be set to MONO.
  343.      (QES)
  344.  
  345.      monitor.0       - 2
  346.      monitor.1       - COLOR|MONO
  347.      monitor.2       - COLOR|MONO
  348.  
  349. MSGMode
  350.      Indicates if MSGMODE setting is on or off.
  351.      (QES)
  352.  
  353.      msgmode.0       - 1
  354.      msgmode.1       - ON|OFF
  355.  
  356. NBFile
  357.      Returns with the number of files currently in the ring.
  358.      (QES)
  359.  
  360.      nbfile.0        - 1
  361.      nbfile.1        - Number of files in ring
  362.  
  363. NEWLines
  364.      Indicates if NEWLINES variable is set to LEFT or ALIGNED.
  365.      (QES)
  366.  
  367.      newlines.0      - 1
  368.      newlines.1      - ALIGNED|LEFT
  369.  
  370. NONDisp
  371.      Returns the character that is displayed for extended characters
  372.      that are not displayed.
  373.      (QES)
  374.  
  375.      nondisp.0       - 1
  376.      nondisp.1       - char
  377.  
  378. NUMber
  379.      Indicates if line numbers are displayed in the prefix area.
  380.      (QES)
  381.  
  382.      number.0        - 1
  383.      number.1        - ON|OFF
  384.  
  385. PENDing [BLOCK] [OLDNAME] name|*
  386.      Returns information about pening prefix commands.
  387.      (E)
  388.  
  389.      pending.0       - 4
  390.      pending.1       - line number in file
  391.      pending.2       - newname - actual name entered in prefix area
  392.      pending.3       - oldname - original name of macro after
  393.                                  synonym resolution
  394.      pending.4       - BLOCK or null
  395.  
  396. Point [*]
  397.      Returns the name and line number of the focus line, or names and
  398.      line numbers of all lines in a file if '*' is specified.
  399.      (E)
  400.  
  401.      When 'EXTract /Point' is specified:
  402.  
  403.      point.0         - 0 or 1       (0 if focus line not named)
  404.      point.1         - line number and name of line (if line is named)
  405.  
  406.      When 'EXTract /Point *' is specified:
  407.  
  408.      point.0         - number of named lines in the file
  409.      point.1         - line number and name for first named line
  410.      point.n         - line number and name for nth named line
  411.  
  412. PREfix [Synonym name|*]
  413.      Indicates if prefix is displayed for the view and if displayed
  414.      where is is displayed.
  415.      (QES)
  416.  
  417.      prefix.0        - 1 or 2     (1 if prefix.1 is OFF, 2 otherwise)
  418.      prefix.1        - ON|OFF
  419.      prefix.2        - LEFT|RIGHT                 (if prefix.1 is ON)
  420.  
  421.      With [Synonym name] option, the name of the macrofile (oldname) 
  422.      is returned that is associated with the synonym, name. If name 
  423.      is not a synonym then name is returned.
  424.      (E)
  425.  
  426.      prefix.0        - 1
  427.      prefix.1        - oldname
  428.  
  429.      With [Synonym *] option, all prefix synonyms are returned.
  430.      (E)
  431.  
  432.      prefix.0        - number of prefix synonyms
  433.      prefix.1        - newname oldname
  434.      prefix.n        - newname oldname
  435.  
  436. PRINTER
  437.      Returns the value of the printer port or spooler.
  438.      (QES)
  439.  
  440.      printer.0       - 1
  441.      printer.1       - port or spooler name
  442.  
  443. REPROFile
  444.      Indicates if the profile file is to be re-executed for each
  445.      subsequent file to be edited.
  446.      (QES)
  447.  
  448.      reprofile.0     - 1
  449.      reprofile.1     - ON|OFF
  450.  
  451. REXXOUTput
  452.      Indicates if REXX output is captured to a file or not and the
  453.      line number limit of lines to be displayed.
  454.      (QES)
  455.  
  456.      rexxoutput.0    - 2
  457.      rexxoutput.1    - FILE|DISPLAY
  458.      rexxoutput.2    - line number limit
  459.  
  460. SIze
  461.      Returns the number of lines in the current file.
  462.      (QES)
  463.  
  464.      size.0          - 1
  465.      size.1          - Lines in current file.
  466.  
  467. STAY
  468.      Indicates if STAY is on or off.
  469.      (QES)
  470.  
  471.      stay.0          - 1
  472.      stay.1          - ON|OFF
  473.  
  474. TABKey
  475.      Returns settings about behaviour of TAB key.
  476.      tabkey.1 is behaviour while in insert mode
  477.      tabkey.2 is behaviour while not in insert mode
  478.      (QES)
  479.  
  480.      tabkey.0        - 2
  481.      tabkey.1        - TAB|CHARACTER
  482.      tabkey.2        - TAB|CHARACTER
  483.  
  484. TABS
  485.      Returns settings about tab columns.
  486.      (QES)
  487.  
  488.      tabs.0          - 2
  489.      tabs.1          - INCR
  490.      tabs.2          - size of tab
  491.  
  492. TABSIn
  493.      Indicates if TABSIN processing is on or off and the size of the
  494.      tabs setting.
  495.      (QES)
  496.  
  497.      tabsin.0        - 2
  498.      tabsin.1        - ON|OFF
  499.      tabsin.2        - size of tabs
  500.  
  501. TABSOut
  502.      Indicates if TABSOUT processing is on or off and the size of the
  503.      tabs setting.
  504.      (QES)
  505.  
  506.      tabsout.0       - 2
  507.      tabsout.1       - ON|OFF
  508.      tabsout.2       - size of tabs
  509.  
  510. TERMinal
  511.      Identifies the terminal type currently being used.
  512.      (QES)
  513.  
  514.      terminal.0      - 1
  515.      terminal.1      - DOS|OS2|$TERM value under Unix
  516.  
  517. TOF
  518.      Indicates if the current line is on the *** Top of file *** line.
  519.      (QES)
  520.  
  521.      tof.0           - 1
  522.      tof.2           - ON|OFF
  523.  
  524. Verify
  525.      Returns verify column settings.
  526.      (QES)
  527.  
  528.      verify.0        - 1
  529.      verify.1        - Column pair of verify start and end columns.
  530.  
  531. VERSION
  532.      Returns information about name of application (THE) and version
  533.      information.
  534.      (QES)
  535.  
  536.      version.0       - 4
  537.      version.1       - THE
  538.      version.3       - version string eg. 1.5
  539.      version.3       - platform version (DOS,OS2,UNIX)
  540.      version.4       - version status information eg. beta
  541.  
  542. Width
  543.      Returns maximum line width setting.
  544.      (QES)
  545.  
  546.      width.0         - 1
  547.      width.1         - Maximum line width value.
  548.  
  549. WORDWrap
  550.      Indicates if WORDWARP is on or off.
  551.      (QES)
  552.  
  553.      wordwrap.0      - 1
  554.      wordwrap.1      - ON|OFF
  555.  
  556. Zone
  557.      Returns zone column settings.
  558.      (QES)
  559.  
  560.      zone.0          - 2
  561.      zone.1          - Zone start column
  562.      zone.2          - Zone end column
  563.  
  564.  
  565.  
  566. ========================================================================
  567. IMPLIED EXTRACT, BOOLEAN and OTHER FUNCTIONS
  568. ========================================================================
  569.  
  570. IMPLIED EXTRACT
  571.  
  572.      The above REXX variables set above by the EXTRACT command may also
  573.      be obtained by a REXX macro as an implied EXTRACT. Each variable
  574.      above that may be set by an explicit EXTRACT command may also be
  575.      used as an external function to REXX to obtain the same information.
  576.      eg. The REXX commands:
  577.  
  578.          'EXTRACT /SIZE/CURLINE/'
  579.          Say size.1 curline.1
  580.  
  581.      may be substituted with:
  582.  
  583.          Say size.1() curline.1()
  584.  
  585. BOOLEAN FUNCTIONS
  586.  
  587.      THE also provides other information to the REXX interpreter via
  588.      boolean functions. These functions return either '1' or '0'
  589.      depending on the information queried.
  590.  
  591.   after()
  592.      Returns '1' if the cursor is currently after the last non-blank
  593.      character on the line, or if the line is blank.
  594.  
  595.   blank()
  596.      Returns '1' if the line the cursor is on is completely blank.
  597.  
  598.   block()
  599.      Returns '1' if the marked block is within the current view.
  600.  
  601.   before()
  602.      Returns '1' if the cursor is currently before the first non-blank
  603.      character on the line, or if the line is blank.
  604.  
  605.   bottomedge()
  606.      Returns '1' if the cursor is on the bottom edge of the filearea
  607.      or prefix area.
  608.  
  609.   command()
  610.      Returns '1' if the cursor is on the command line.
  611.  
  612.   current()
  613.      Returns '1' if the cursor is on the current line.
  614.  
  615.   dir()
  616.      Returns '1' if the current file is the special DIR.DIR file.
  617.  
  618.   end()
  619.      Returns '1' if the cursor is on the last non-blank character on
  620.      the line.
  621.  
  622.   eof()
  623.      Returns '1' if the cursor is on the '*** Bottom of file ***' line
  624.      and the cursor is not on the command line.
  625.  
  626.   first()
  627.      Returns '1' if the cursor is in column 1 of the current window.
  628.  
  629.   focuseof()
  630.      Returns '1' if the focus line is the '*** Bottom of file ***' line
  631.      whether the cursor is on it or not.
  632.  
  633.   focustof()
  634.      Returns '1' if the focus line is the '*** Top of file ***' line
  635.      whether the cursor is on it or not.
  636.  
  637.   inblock()
  638.      Returns '1' if the cursor is in the marked block.
  639.  
  640.   initial()
  641.      Returns '1' if the function is called from the profile file.
  642.  
  643.   inprefix()
  644.      Returns '1' if the cursor is located in the prefix area.
  645.  
  646.   leftedge()
  647.      Returns '1' if the cursor is on the left edge of the file area.
  648.  
  649.   modifiable()
  650.      Returns '1' if the cursor is located in an area that can be changed.
  651.      ie. not on '*** Top of File ***' or '*** Bottom of File ***' lines.
  652.  
  653.   rightedge()
  654.      Returns '1' if the cursor is on the right edge of the file area.
  655.  
  656.   spacechar()
  657.      Returns '1' if the cursor is on a space character.
  658.  
  659.   tof()
  660.      Returns '1' if the cursor is on the '*** Top of file ***' line
  661.      and the cursor is not on the command line.
  662.  
  663.   topedge()
  664.      Returns '1' if the cursor is on the top edge of the file area.
  665.  
  666.   verone()
  667.      Returns '1' if the column 1 of the file is being displayed in
  668.      column 1.
  669.  
  670. OTHER FUNCTIONS
  671.  
  672.    The following functions provide functions to simplify THE macros
  673.    written in REXX.
  674.  
  675.   valid_target(target)
  676.      Returns 0 if the supplied 'target' is invalid.
  677.      Returns 'ALL' if the supplied 'target' is 'ALL'.
  678.      If a valid target, returns the number of lines from the focus
  679.      line to the 'target', either positive if the target is toward the
  680.      end of file or negative if the target is toward the top of file.
  681.  
  682. **man-end**********************************************************************/
  683.  
  684. struct query_item
  685.  {
  686.   char query;                                /* valid query response ? */
  687.   char *name;                                          /* name of item */
  688.   int min_len;                       /* minimum length of abbreviation */
  689.   int item_number;                           /* unique number for item */
  690.   int number_values;                      /* number of values returned */
  691.  };
  692. typedef struct query_item QUERY_ITEM;
  693.  
  694. /***********************************************************************/
  695. /* Keep the following items in alphabetic order of name.               */
  696. /***********************************************************************/
  697.  static QUERY_ITEM item[] =
  698.   {
  699.    {QUERY_QUERY|QUERY_STATUS|QUERY_EXTRACT             ,"alt",3,ITEM_ALT,2},
  700.    {QUERY_QUERY|QUERY_STATUS|QUERY_EXTRACT|QUERY_MODIFY,"arbchar",3,ITEM_ARBCHAR,2},
  701.    {QUERY_QUERY|QUERY_STATUS|QUERY_EXTRACT|QUERY_MODIFY,"autosave",2,ITEM_AUTOSAVE,1},
  702.    {QUERY_QUERY|QUERY_STATUS|QUERY_EXTRACT|QUERY_MODIFY,"backup",4,ITEM_BACKUP,1},
  703.    {QUERY_QUERY|QUERY_STATUS|QUERY_EXTRACT|QUERY_MODIFY,"beep",4,ITEM_BEEP,1},
  704. #if !defined(NOREXX)
  705.    {                         QUERY_EXTRACT             ,"block",5,ITEM_BLOCK,0},
  706. #else
  707.    {QUERY_NONE                                         ,"block",5,ITEM_BLOCK,0},
  708. #endif
  709.    {QUERY_QUERY|QUERY_STATUS|QUERY_EXTRACT|QUERY_MODIFY,"case",4,ITEM_CASE,4},
  710.    {QUERY_QUERY|QUERY_STATUS|QUERY_EXTRACT|QUERY_MODIFY,"clearscreen",6,ITEM_CLEARSCREEN,1},
  711.    {QUERY_QUERY|QUERY_STATUS|QUERY_EXTRACT|QUERY_MODIFY,"clock",5,ITEM_CLOCK,1},
  712.    {QUERY_QUERY|QUERY_STATUS|QUERY_EXTRACT|QUERY_MODIFY,"cmdarrows",4,ITEM_CMDARROWS,3},
  713.    {QUERY_QUERY|QUERY_STATUS|QUERY_EXTRACT|QUERY_MODIFY,"cmdline",3,ITEM_CMDLINE,2},
  714.    {                         QUERY_EXTRACT|QUERY_MODIFY,"curline",3,ITEM_CURLINE,3},
  715. #if !defined(NOREXX)
  716.    {                         QUERY_EXTRACT             ,"dirfileid",9,ITEM_DIRFILEID,2},
  717. #else
  718.    {QUERY_NONE                                         ,"dirfileid",9,ITEM_DIRFILEID,2},
  719. #endif
  720.    {QUERY_QUERY|QUERY_STATUS|QUERY_EXTRACT             ,"eof",3,ITEM_EOF,1},
  721.    {QUERY_QUERY|QUERY_STATUS|QUERY_EXTRACT|QUERY_MODIFY,"eolout",3,ITEM_EOLOUT,1},
  722.    {QUERY_QUERY|QUERY_STATUS|QUERY_EXTRACT|QUERY_MODIFY,"etmode",6,ITEM_ETMODE,1},
  723. #if !defined(NOREXX)
  724.    {                         QUERY_EXTRACT             ,"fname",5,ITEM_FNAME,1},
  725.    {                         QUERY_EXTRACT             ,"fpath",5,ITEM_FPATH,1},
  726.    {                         QUERY_EXTRACT             ,"ftype",5,ITEM_FTYPE,1},
  727.    {                         QUERY_EXTRACT             ,"getenv",6,ITEM_GETENV,1},
  728. #else
  729.    {QUERY_NONE                                         ,"fname",5,ITEM_FNAME,1},
  730.    {QUERY_NONE                                         ,"fpath",5,ITEM_FPATH,1},
  731.    {QUERY_NONE                                         ,"ftype",5,ITEM_FTYPE,1},
  732.    {QUERY_NONE                                         ,"getenv",6,ITEM_GETENV,1},
  733. #endif
  734.    {QUERY_QUERY|QUERY_STATUS|QUERY_EXTRACT|QUERY_MODIFY,"hex",3,ITEM_HEX,1},
  735.    {QUERY_QUERY|QUERY_STATUS|QUERY_EXTRACT|QUERY_MODIFY,"hexdisplay",7,ITEM_HEXDISPLAY,1},
  736.    {QUERY_QUERY|QUERY_STATUS|QUERY_EXTRACT|QUERY_MODIFY,"impmacro",6,ITEM_IMPMACRO,1},
  737.    {QUERY_QUERY|QUERY_STATUS|QUERY_EXTRACT|QUERY_MODIFY,"impos",5,ITEM_IMPOS,1},
  738.    {QUERY_QUERY|QUERY_STATUS|QUERY_EXTRACT|QUERY_MODIFY,"insertmode",6,ITEM_INSERTMODE,1},
  739. #if !defined(NOREXX)
  740.    {                         QUERY_EXTRACT             ,"lastmsg",4,ITEM_LASTMSG,1},
  741. #else
  742.    {QUERY_NONE                                         ,"lastmsg",4,ITEM_LASTMSG,1},
  743. #endif
  744.    {QUERY_QUERY|QUERY_STATUS|QUERY_EXTRACT             ,"lastrc",6,ITEM_LASTRC,1},
  745.    {QUERY_QUERY|QUERY_STATUS|QUERY_EXTRACT             ,"length",3,ITEM_LENGTH,1},
  746.    {QUERY_QUERY|QUERY_STATUS|QUERY_EXTRACT             ,"line",2,ITEM_LINE,1},
  747.    {QUERY_QUERY|QUERY_STATUS|QUERY_EXTRACT             ,"linend",5,ITEM_LINEND,2},
  748.    {QUERY_QUERY|QUERY_STATUS|QUERY_EXTRACT|QUERY_MODIFY,"macroext",6,ITEM_MACROEXT,1},
  749.    {QUERY_QUERY|QUERY_STATUS|QUERY_EXTRACT|QUERY_MODIFY,"macropath",6,ITEM_MACROPATH,1},
  750.    {QUERY_QUERY|QUERY_STATUS|QUERY_EXTRACT|QUERY_MODIFY,"margins",3,ITEM_MARGINS,3},
  751.    {QUERY_QUERY|QUERY_STATUS|QUERY_EXTRACT             ,"monitor",7,ITEM_MONITOR,2},
  752.    {QUERY_QUERY|QUERY_STATUS|QUERY_EXTRACT|QUERY_MODIFY,"msgmode",4,ITEM_MSGMODE,1},
  753.    {QUERY_QUERY|QUERY_STATUS|QUERY_EXTRACT             ,"nbfile",3,ITEM_NBFILE,1},
  754.    {QUERY_QUERY|QUERY_STATUS|QUERY_EXTRACT|QUERY_MODIFY,"newlines",4,ITEM_NEWLINES,1},
  755.    {QUERY_QUERY|QUERY_STATUS|QUERY_EXTRACT|QUERY_MODIFY,"nondisp",4,ITEM_NONDISP,1},
  756.    {QUERY_QUERY|QUERY_STATUS|QUERY_EXTRACT|QUERY_MODIFY,"number",3,ITEM_NUMBER,1},
  757. #if !defined(NOREXX)
  758.    {                         QUERY_EXTRACT             ,"pending",4,ITEM_PENDING,4},
  759. #else
  760.    {QUERY_NONE                                         ,"pending",4,ITEM_PENDING,4},
  761. #endif
  762. #if !defined(NOREXX)
  763.    {                         QUERY_EXTRACT             ,"point",1,ITEM_POINT,0},
  764. #else
  765.    {QUERY_NONE                                         ,"point",1,ITEM_POINT,0},
  766. #endif
  767.    {QUERY_QUERY|QUERY_STATUS|QUERY_EXTRACT|QUERY_MODIFY,"prefix",3,ITEM_PREFIX,0},
  768.    {QUERY_QUERY|QUERY_STATUS|QUERY_EXTRACT|QUERY_MODIFY,"printer",7,ITEM_PRINTER,1},
  769.    {QUERY_QUERY|QUERY_STATUS|QUERY_EXTRACT|QUERY_MODIFY,"reprofile",6,ITEM_REPROFILE,1},
  770. #if !defined(NOREXX)
  771.    {QUERY_QUERY|QUERY_STATUS|QUERY_EXTRACT|QUERY_MODIFY,"rexxoutput",7,ITEM_REXXOUTPUT,2},
  772. #else
  773.    {QUERY_NONE                                         ,"rexxoutput",7,ITEM_REXXOUTPUT,2},
  774. #endif
  775.    {QUERY_QUERY|QUERY_STATUS|QUERY_EXTRACT             ,"size",2,ITEM_SIZE,1},
  776.    {QUERY_QUERY|QUERY_STATUS|QUERY_EXTRACT|QUERY_MODIFY,"stay",4,ITEM_STAY,1},
  777.    {QUERY_QUERY|QUERY_STATUS|QUERY_EXTRACT|QUERY_MODIFY,"tabkey",4,ITEM_TABKEY,2},
  778.    {QUERY_QUERY|QUERY_STATUS|QUERY_EXTRACT|QUERY_MODIFY,"tabs",4,ITEM_TABS,2},
  779.    {QUERY_QUERY|QUERY_STATUS|QUERY_EXTRACT|QUERY_MODIFY,"tabsin",5,ITEM_TABSIN,2},
  780.    {QUERY_QUERY|QUERY_STATUS|QUERY_EXTRACT|QUERY_MODIFY,"tabsout",5,ITEM_TABSOUT,2},
  781.    {QUERY_QUERY|QUERY_STATUS|QUERY_EXTRACT             ,"terminal",4,ITEM_TERMINAL,1},
  782.    {QUERY_QUERY|QUERY_STATUS|QUERY_EXTRACT             ,"tof",3,ITEM_TOF,1},
  783.    {QUERY_QUERY|QUERY_STATUS|QUERY_EXTRACT|QUERY_MODIFY,"verify",1,ITEM_VERIFY,1},
  784.    {QUERY_QUERY|QUERY_STATUS|QUERY_EXTRACT             ,"version",7,ITEM_VERSION,4},
  785.    {QUERY_QUERY|QUERY_STATUS|QUERY_EXTRACT             ,"width",1,ITEM_WIDTH,1},
  786.    {QUERY_QUERY|QUERY_STATUS|QUERY_EXTRACT|QUERY_MODIFY,"wordwrap",5,ITEM_WORDWRAP,1},
  787.    {QUERY_QUERY|QUERY_STATUS|QUERY_EXTRACT|QUERY_MODIFY,"zone",1,ITEM_ZONE,2},
  788.    {0                                                   ,NULL,0,0,0},
  789.   };
  790.  
  791. VALUE item_values[MAX_VARIABLES_RETURNED];
  792. /*-------------------------- external data ----------------------------*/
  793. extern VIEW_DETAILS *vd_current,*vd_first,*vd_mark;
  794. /***********************************************************************/
  795. #ifdef PROTO
  796. int find_item(char *item_name,char query_type)
  797. #else
  798. int find_item(item_name,query_type)
  799. char *item_name;
  800. char query_type;
  801. #endif
  802. /***********************************************************************/
  803. {
  804. /*--------------------------- local data ------------------------------*/
  805.  register int i;
  806.  int itemno = (-1);
  807. /*--------------------------- processing ------------------------------*/
  808. #ifdef TRACE
  809.  trace_function("query.c   :find_item");
  810. #endif
  811. /*---------------------------------------------------------------------*/
  812. /* First find the item to be evaluated...                              */
  813. /*---------------------------------------------------------------------*/
  814.  for (i=0;item[i].name != NULL;i++)
  815.     {
  816.      if (equal(item[i].name,item_name,item[i].min_len)
  817.      && (item[i].query & query_type))
  818.        {
  819.         itemno = item[i].item_number;
  820.         break;
  821.        }
  822.     }
  823. #ifdef TRACE
  824.  trace_return();
  825. #endif
  826.  return(itemno);
  827. }
  828. /***********************************************************************/
  829. #ifdef PROTO
  830. int show_status(void)
  831. #else
  832. int show_status()
  833. #endif
  834. /***********************************************************************/
  835. {
  836. /*-------------------------- external data ----------------------------*/
  837. extern WINDOW *foot;
  838. /*--------------------------- local data ------------------------------*/
  839.  register int i,j;
  840.  int lineno=0,colno=0;
  841.  int number_variables;
  842.  bool left_col = TRUE;
  843.  int item_width,column,column_width,col[3];
  844. /*--------------------------- processing ------------------------------*/
  845. #ifdef TRACE
  846.  trace_function("query.c   :show_status");
  847. #endif
  848. /*---------------------------------------------------------------------*/
  849. /* For each item that is displayable, display it...                    */
  850. /*---------------------------------------------------------------------*/
  851.  column = 0;
  852.  column_width = COLS / 3;
  853.  col[0] = 0;
  854.  col[1] = column_width+1;
  855.  col[2] = col[1]+column_width+1;
  856.  wclear(stdscr);
  857.  for (i=0;item[i].name != NULL;i++)
  858.     {
  859. /*---------------------------------------------------------------------*/
  860. /* Get only those settings that are queryable...                       */
  861. /*---------------------------------------------------------------------*/
  862.      if (item[i].query & QUERY_STATUS)
  863.        {
  864.         number_variables = get_item_values(item[i].item_number,"",QUERY_STATUS,0L,NULL,0L);
  865.         item_width = 0;
  866. /*---------------------------------------------------------------------*/
  867. /* Obtain the total length of the setting values...                    */
  868. /*---------------------------------------------------------------------*/
  869.         for (j=0;j<number_variables+1;j++)
  870.            item_width += item_values[j].len+1;
  871.         item_width--;     /* reduce by 1 for last value's blank at end */
  872. /*---------------------------------------------------------------------*/
  873. /* If the length of the variables is > the screen width, go to next    */
  874. /* line.                                                               */
  875. /*---------------------------------------------------------------------*/
  876.         if (item_width+col[column] > COLS)
  877.           {
  878.            column = colno = 0;
  879.            lineno++;
  880.           }
  881.         else
  882.            colno = col[column];
  883. /*---------------------------------------------------------------------*/
  884. /* Display the variables. For the first value, display in BOLD.        */
  885. /*---------------------------------------------------------------------*/
  886.         for (j=0;j<number_variables+1;j++)
  887.           {
  888.            if (j == 0)
  889.               attrset(A_BOLD);
  890.            mvaddstr(lineno,colno,item_values[j].value);
  891.            attrset(A_NORMAL);
  892.            colno += item_values[j].len+1;
  893.           }
  894. /*---------------------------------------------------------------------*/
  895. /* Now have to determine where to display the next set of variables... */
  896. /* If the just-displayed values go past the last column, or we are     */
  897. /* already in the last column, go to the next line...                  */
  898. /*---------------------------------------------------------------------*/
  899.         if (colno >= col[2] || column == 2)
  900.           {
  901.            lineno++;
  902.            column = 0;
  903.           }
  904.         else
  905.           {
  906. /*---------------------------------------------------------------------*/
  907. /* ...else if the the just-displayed values go past the 2nd column...  */
  908. /* If the just-displayed values go past the last column, go on to the  */
  909. /* next line...                                                        */
  910. /*---------------------------------------------------------------------*/
  911.            if (colno >= col[1])
  912.               column = 2;
  913.            else
  914. /*---------------------------------------------------------------------*/
  915. /* ...else go to the next column.                                      */
  916. /*---------------------------------------------------------------------*/
  917.               column++;
  918.           }
  919.        }
  920.     }
  921.  mvaddstr(LINES-2,0,HIT_ANY_KEY);
  922.  refresh();
  923.  (void)my_getch(stdscr);
  924.  wclear(stdscr);
  925.  refresh();
  926.  
  927.  restore_THE();
  928.  
  929. #ifdef TRACE
  930.  trace_return();
  931. #endif
  932.  return(RC_OK);
  933. }
  934. /***********************************************************************/
  935. #ifdef PROTO
  936. int save_status(char *filename)
  937. #else
  938. int save_status(filename)
  939. char *filename;
  940. #endif
  941. /***********************************************************************/
  942. {
  943. /*-------------------------- external data ----------------------------*/
  944.  extern char sp_path[MAX_FILE_NAME+1] ;
  945.  extern char sp_fname[MAX_FILE_NAME+1] ;
  946.  extern char *the_version;
  947. /*--------------------------- local data ------------------------------*/
  948.  register int i,j;
  949.  int number_variables,rc;
  950.  FILE *fp;
  951. /*--------------------------- processing ------------------------------*/
  952. #ifdef TRACE
  953.  trace_function("query.c   :save_status");
  954. #endif
  955. /*---------------------------------------------------------------------*/
  956. /* Get the fully qualified filename from the supplied filename.        */
  957. /*---------------------------------------------------------------------*/
  958.  strtrans(filename,OSLASH,ISLASH);
  959.  if ((rc = splitpath(filename)) != RC_OK)
  960.    {
  961.     display_error(10,filename);
  962. #ifdef TRACE
  963.     trace_return();
  964. #endif
  965.     return(rc);
  966.    }
  967. /*---------------------------------------------------------------------*/
  968. /* splitpath() has set up sp_path  and sp_fname. Append the filename.  */
  969. /*---------------------------------------------------------------------*/
  970.  strcat(sp_path,sp_fname);
  971. /*---------------------------------------------------------------------*/
  972. /* If the file already exists, display an error.                       */
  973. /*---------------------------------------------------------------------*/
  974.   if (file_exists(sp_path))
  975.    {
  976.     display_error(8,filename);
  977. #ifdef TRACE
  978.     trace_return();
  979. #endif
  980.     return(rc);
  981.    }
  982.  fp = fopen(sp_path,"w");
  983. /*---------------------------------------------------------------------*/
  984. /* For each item that is modifiable, get its value...                  */
  985. /*---------------------------------------------------------------------*/
  986.  fprintf(fp,"/* This file generated by STATUS command of THE %s */\n",the_version);
  987.  for (i=0;item[i].name != NULL;i++)
  988.     {
  989. /*---------------------------------------------------------------------*/
  990. /* Get only those settings that are modifiable...                      */
  991. /*---------------------------------------------------------------------*/
  992.      if (item[i].query & QUERY_MODIFY)
  993.        {
  994.         number_variables = get_item_values(item[i].item_number,"",QUERY_MODIFY,0L,NULL,0L);
  995.         fputs("'set",fp);
  996. /*---------------------------------------------------------------------*/
  997. /* Write the variables to the file...                                  */
  998. /*---------------------------------------------------------------------*/
  999.         for (j=0;j<number_variables+1;j++)
  1000.           {
  1001.            fputc(' ',fp);
  1002.            fputs(item_values[j].value,fp);
  1003.           }
  1004.         fprintf(fp,"'\n");
  1005.        }
  1006.     }
  1007.  fflush(fp);
  1008.  fclose(fp);
  1009. #ifdef TRACE
  1010.  trace_return();
  1011. #endif
  1012.  return(RC_OK);
  1013. }
  1014. /***********************************************************************/
  1015. #ifdef PROTO
  1016. int get_item_values(int itemno,char *itemargs,char query_type,unsigned long argc,char *arg,unsigned long arglen)
  1017. #else
  1018. int get_item_values(itemno,itemargs,query_type,argc,arg,arglen)
  1019. int itemno;
  1020. char *itemargs;
  1021. char query_type;
  1022. unsigned long argc;
  1023. char *arg;
  1024. unsigned long arglen;
  1025. #endif
  1026. /***********************************************************************/
  1027. {
  1028. /*-------------------------- external data ----------------------------*/
  1029. extern char term_name[20];
  1030. extern char dir_path[MAX_FILE_NAME+1];
  1031. extern char *temp_cmd;
  1032. extern unsigned short file_start;
  1033. extern char *the_version;
  1034. extern short max_line_length;
  1035. extern char the_macro_path[MAX_FILE_NAME+1];
  1036. extern char macro_suffix[12];
  1037. extern char CLEARSCREENx;
  1038. extern char CMDARROWSTABCMDx;
  1039. extern char CMDARROWSTABTXTx;
  1040. extern char CMDARROWSTABLRx;
  1041. extern char REPROFILEx;
  1042. extern bool CAPREXXOUTx;
  1043. extern long CAPREXXMAXx;
  1044. extern char TABI_ONx;
  1045. extern char TABI_Nx;
  1046. extern char TABO_ONx;
  1047. extern char TABO_Nx;
  1048. extern bool BEEPx;
  1049. extern bool CLOCKx;
  1050. extern bool HEXDISPLAYx;
  1051. extern char number_of_files;
  1052. extern char mode_insert;
  1053. extern char tabkey_insert;
  1054. extern char tabkey_overwrite;
  1055. extern int lastrc;
  1056. extern char last_message[160];
  1057. extern char in_profile;
  1058. extern unsigned short rec_len;
  1059. extern unsigned short cmd_rec_len;
  1060. extern unsigned short pre_rec_len;
  1061. extern char current_screen;
  1062. extern SCREEN_DETAILS screen[MAX_SCREENS];
  1063. extern bool colour_support;
  1064. extern bool extended_display_mode;
  1065. extern bool NONDISPx;
  1066. extern long prefix_current_line;
  1067. extern bool in_prefix_macro;
  1068. extern char *cmd_rec;
  1069. extern char *rec;
  1070.  
  1071. #if defined(UNIX) || defined(OS2)
  1072. extern char *spooler_name;
  1073. #endif
  1074. /*--------------------------- local data ------------------------------*/
  1075.  static char num0[3];
  1076.  static char num1[7];
  1077.  static char num2[7];
  1078.  static char num3[15];
  1079.  static char num4[15];
  1080.  static LINE *curr;
  1081.  int y,x,rc,i;
  1082.  int number_variables = item[itemno].number_values;
  1083.  long true_line,num_lines;
  1084.  bool bool_flag;
  1085.  char cursor_char;
  1086.  char *tmpbuf;
  1087. /*--------------------------- processing ------------------------------*/
  1088. #ifdef TRACE
  1089.  trace_function("query.c:   get_item_values");
  1090. #endif
  1091. /*---------------------------------------------------------------------*/
  1092. /* Now that we have a valid itme, set up its values...                 */
  1093. /*---------------------------------------------------------------------*/
  1094.  switch(itemno)
  1095.    {
  1096. #if !defined(NOREXX)
  1097.     case ITEM_AFTER_FUNCTION:
  1098.          getyx(CURRENT_WINDOW,y,x);
  1099.          bool_flag = FALSE;
  1100.          switch(CURRENT_VIEW->current_window)
  1101.            {
  1102.             case WINDOW_MAIN:
  1103.                  if ((x+CURRENT_VIEW->verify_col-1) >= rec_len)
  1104.                     bool_flag = TRUE;
  1105.                  break;
  1106.             case WINDOW_COMMAND:
  1107.                  if (x >= cmd_rec_len)
  1108.                     bool_flag = TRUE;
  1109.                  break;
  1110.             case WINDOW_PREFIX:
  1111.                  if (x >= pre_rec_len)
  1112.                     bool_flag = TRUE;
  1113.                  break;
  1114.            }
  1115.          if (bool_flag)
  1116.            {
  1117.             item_values[1].value = "1";
  1118.             item_values[1].len = 1;
  1119.            }
  1120.           else
  1121.            {
  1122.             item_values[1].value = "0";
  1123.             item_values[1].len = 1;
  1124.            }
  1125.          break;
  1126. #endif
  1127.     case ITEM_ALT:
  1128.          sprintf(num1,"%d",CURRENT_FILE->autosave_alt);
  1129.          sprintf(num2,"%d",CURRENT_FILE->save_alt);
  1130.          item_values[1].value = num1;
  1131.          item_values[2].value = num2;
  1132.          item_values[1].len = strlen(num1);
  1133.          item_values[2].len = strlen(num2);
  1134.          break;
  1135.     case ITEM_ARBCHAR:
  1136.          if (CURRENT_VIEW->arbchar_status)
  1137.            {
  1138.             item_values[1].value = "ON";
  1139.             item_values[1].len = 2;
  1140.            }
  1141.          else
  1142.            {
  1143.             item_values[1].value = "OFF";
  1144.             item_values[1].len = 3;
  1145.            }
  1146.          num1[0] = CURRENT_VIEW->arbchar_char;
  1147.          num1[1] ='\0';
  1148.          item_values[2].value = num1;
  1149.          item_values[2].len = 1;
  1150.          break;
  1151.     case ITEM_AUTOSAVE:
  1152.          sprintf(num1,"%d",CURRENT_FILE->autosave);
  1153.          item_values[1].value = num1;
  1154.          item_values[1].len = strlen(num1);
  1155.          if (CURRENT_FILE->autosave == 0)
  1156.            {
  1157.             item_values[1].value = "OFF";
  1158.             item_values[1].len = 3;
  1159.            }
  1160.          break;
  1161.     case ITEM_BACKUP:
  1162.          if (CURRENT_FILE->backup)
  1163.            {
  1164.             item_values[1].value = "ON";
  1165.             item_values[1].len = 2;
  1166.            }
  1167.           else
  1168.            {
  1169.             item_values[1].value = "OFF";
  1170.             item_values[1].len = 3;
  1171.            }
  1172.          break;
  1173. #if !defined(NOREXX)
  1174.     case ITEM_BEFORE_FUNCTION:
  1175.          getyx(CURRENT_WINDOW,y,x);
  1176.          bool_flag = FALSE;
  1177.          switch(CURRENT_VIEW->current_window)
  1178.            {
  1179.             case WINDOW_MAIN:
  1180.                  if ((x+CURRENT_VIEW->verify_col-1) < memne(rec,' ',rec_len))
  1181.                     bool_flag = TRUE;
  1182.                  break;
  1183.             case WINDOW_COMMAND:
  1184.                  if (x < memne(cmd_rec,' ',cmd_rec_len))
  1185.                     bool_flag = TRUE;
  1186.                  break;
  1187.             case WINDOW_PREFIX:/* cursor can't go before 1st non-blank */
  1188.                  break;
  1189.            }
  1190.          if (bool_flag)
  1191.            {
  1192.             item_values[1].value = "1";
  1193.             item_values[1].len = 1;
  1194.            }
  1195.           else
  1196.            {
  1197.             item_values[1].value = "0";
  1198.             item_values[1].len = 1;
  1199.            }
  1200.          break;
  1201. #endif
  1202.     case ITEM_BEEP:
  1203.          if (BEEPx)
  1204.            {
  1205.             item_values[1].value = "ON";
  1206.             item_values[1].len = 2;
  1207.            }
  1208.           else
  1209.            {
  1210.             item_values[1].value = "OFF";
  1211.             item_values[1].len = 3;
  1212.            }
  1213.          break;
  1214. #if !defined(NOREXX)
  1215.     case ITEM_BLANK_FUNCTION:
  1216.          bool_flag = FALSE;
  1217.          switch(CURRENT_VIEW->current_window)
  1218.            {
  1219.             case WINDOW_MAIN:
  1220.                  if (rec_len == 0)
  1221.                     bool_flag = TRUE;
  1222.                  break;
  1223.             case WINDOW_PREFIX:
  1224.                  if (pre_rec_len == 0)
  1225.                     bool_flag = TRUE;
  1226.                  break;
  1227.             case WINDOW_COMMAND:
  1228.                  if (cmd_rec_len == 0)
  1229.                     bool_flag = TRUE;
  1230.                  break;
  1231.            }
  1232.          if (bool_flag)
  1233.            {
  1234.             item_values[1].value = "1";
  1235.             item_values[1].len = 1;
  1236.            }
  1237.           else
  1238.            {
  1239.             item_values[1].value = "0";
  1240.             item_values[1].len = 1;
  1241.            }
  1242.          break;
  1243. #endif
  1244. #if !defined(NOREXX)
  1245.     case ITEM_BLOCK:
  1246.          if (MARK_VIEW == NULL)
  1247.            {
  1248.             item_values[1].value = "NONE";
  1249.             item_values[1].len = 4;
  1250.             number_variables = 1;
  1251.            }
  1252.           else
  1253.            {
  1254.             number_variables = 6;
  1255.             if (MARK_VIEW->mark_type == M_LINE)
  1256.               {
  1257.                item_values[1].value = "LINE";
  1258.                item_values[1].len = 4;
  1259.               }
  1260.             else
  1261.               {
  1262.                item_values[1].value = "BOX";
  1263.                item_values[1].len = 3;
  1264.               }
  1265.             sprintf(num1,"%d",MARK_VIEW->mark_start_line);
  1266.             item_values[2].value = num1;
  1267.             item_values[2].len = strlen(num1);
  1268.             sprintf(num2,"%d",MARK_VIEW->mark_start_col);
  1269.             item_values[3].value = num2;
  1270.             item_values[3].len = strlen(num2);
  1271.             sprintf(num3,"%d",MARK_VIEW->mark_end_line);
  1272.             item_values[4].value = num3;
  1273.             item_values[4].len = strlen(num3);
  1274.             sprintf(num4,"%d",MARK_VIEW->mark_end_col);
  1275.             item_values[5].value = num4;
  1276.             item_values[5].len = strlen(num4);
  1277.             strcpy(temp_cmd,MARK_FILE->fpath);
  1278.             strcat(temp_cmd,MARK_FILE->fname);
  1279.             item_values[6].value = (char *)temp_cmd;
  1280.             item_values[6].len = strlen(temp_cmd);
  1281.            }
  1282.          break;
  1283. #endif
  1284. #if !defined(NOREXX)
  1285.     case ITEM_BLOCK_FUNCTION:
  1286.          if (CURRENT_VIEW == MARK_VIEW)
  1287.            {
  1288.             item_values[1].value = "1";
  1289.             item_values[1].len = 1;
  1290.            }
  1291.           else
  1292.            {
  1293.             item_values[1].value = "0";
  1294.             item_values[1].len = 1;
  1295.            }
  1296.          break;
  1297. #endif
  1298. #if !defined(NOREXX)
  1299.     case ITEM_BOTTOMEDGE_FUNCTION:
  1300.          getyx(CURRENT_WINDOW,y,x);
  1301.          if (CURRENT_VIEW->current_window == WINDOW_MAIN
  1302.          &&  y == CURRENT_SCREEN.rows-1)
  1303.            {
  1304.             item_values[1].value = "1";
  1305.             item_values[1].len = 1;
  1306.            }
  1307.           else
  1308.            {
  1309.             item_values[1].value = "0";
  1310.             item_values[1].len = 1;
  1311.            }
  1312.          break;
  1313. #endif
  1314.     case ITEM_CASE:
  1315.          switch(CURRENT_VIEW->case_enter)
  1316.            {
  1317.             case CASE_MIXED:
  1318.                  item_values[1].value = "MIXED";
  1319.                  break;
  1320.             case CASE_UPPER:
  1321.                  item_values[1].value = "UPPER";
  1322.                  break;
  1323.             case CASE_LOWER:
  1324.                  item_values[1].value = "LOWER";
  1325.                  break;
  1326.             default:
  1327.                  break;
  1328.            }
  1329.          item_values[1].len = 5;
  1330.          switch(CURRENT_VIEW->case_locate)
  1331.            {
  1332.             case CASE_IGNORE:
  1333.                  item_values[2].value = "IGNORE";
  1334.                  item_values[2].len = 6;
  1335.                  break;
  1336.             case CASE_RESPECT:
  1337.                  item_values[2].value = "RESPECT";
  1338.                  item_values[2].len = 7;
  1339.                  break;
  1340.             default:
  1341.                  break;
  1342.            }
  1343.          switch(CURRENT_VIEW->case_change)
  1344.            {
  1345.             case CASE_IGNORE:
  1346.                  item_values[3].value = "IGNORE";
  1347.                  item_values[3].len = 6;
  1348.                  break;
  1349.             case CASE_RESPECT:
  1350.                  item_values[3].value = "RESPECT";
  1351.                  item_values[3].len = 7;
  1352.                  break;
  1353.             default:
  1354.                  break;
  1355.            }
  1356.          switch(CURRENT_VIEW->case_sort)
  1357.            {
  1358.             case CASE_IGNORE:
  1359.                  item_values[4].value = "IGNORE";
  1360.                  item_values[4].len = 6;
  1361.                  break;
  1362.             case CASE_RESPECT:
  1363.                  item_values[4].value = "RESPECT";
  1364.                  item_values[4].len = 7;
  1365.                  break;
  1366.             default:
  1367.                  break;
  1368.            }
  1369.          break;
  1370.     case ITEM_CLEARSCREEN:
  1371.          if (CLEARSCREENx)
  1372.            {
  1373.             item_values[1].value = "ON";
  1374.             item_values[1].len = 2;
  1375.            }
  1376.           else
  1377.            {
  1378.             item_values[1].value = "OFF";
  1379.             item_values[1].len = 3;
  1380.            }
  1381.          break;
  1382.     case ITEM_CLOCK:
  1383.          if (CLOCKx)
  1384.            {
  1385.             item_values[1].value = "ON";
  1386.             item_values[1].len = 2;
  1387.            }
  1388.           else
  1389.            {
  1390.             item_values[1].value = "OFF";
  1391.             item_values[1].len = 3;
  1392.            }
  1393.          break;
  1394. #if !defined(NOREXX)
  1395.     case ITEM_COMMAND_FUNCTION:
  1396.          if (CURRENT_VIEW->current_window == WINDOW_COMMAND)
  1397.            {
  1398.             item_values[1].value = "1";
  1399.             item_values[1].len = 1;
  1400.            }
  1401.           else
  1402.            {
  1403.             item_values[1].value = "0";
  1404.             item_values[1].len = 1;
  1405.            }
  1406.          break;
  1407. #endif
  1408.     case ITEM_CMDARROWS:
  1409.          if (CMDARROWSTABCMDx)
  1410.            {
  1411.             item_values[1].value = "TAB";
  1412.             item_values[1].len = 3;
  1413.            }
  1414.           else
  1415.            {
  1416.             item_values[1].value = "RETRIEVE";
  1417.             item_values[1].len = 8;
  1418.            }
  1419.          if (CMDARROWSTABTXTx)
  1420.            {
  1421.             item_values[2].value = "TAB";
  1422.             item_values[2].len = 3;
  1423.            }
  1424.           else
  1425.            {
  1426.             item_values[2].value = "SCROLL";
  1427.             item_values[2].len = 6;
  1428.            }
  1429.          if (CMDARROWSTABLRx)
  1430.            {
  1431.             item_values[3].value = "TAB";
  1432.             item_values[3].len = 3;
  1433.            }
  1434.           else
  1435.            {
  1436.             item_values[3].value = "SCROLL";
  1437.             item_values[3].len = 6;
  1438.            }
  1439.          break;
  1440.     case ITEM_CMDLINE:
  1441.          if (CURRENT_VIEW->cmd_line == 'B')
  1442.            {
  1443.             item_values[1].value = "BOTTOM";
  1444.             item_values[1].len = 6;
  1445.            }
  1446.           else
  1447.            {
  1448.             item_values[1].value = "TOP";
  1449.             item_values[1].len = 3;
  1450.            }
  1451.          if (query_type == QUERY_EXTRACT)
  1452.            {
  1453.             getbegyx(CURRENT_WINDOW_COMMAND,y,x);
  1454.             sprintf(num1,"%d",y);
  1455.             item_values[2].value = num1;
  1456.             item_values[2].len = strlen(num1);
  1457.             item_values[3].value = cmd_rec;
  1458.             item_values[3].len = cmd_rec_len;
  1459.             number_variables = 3;
  1460.            }
  1461.          else
  1462.             number_variables = 1;
  1463.          break;
  1464.     case ITEM_CURLINE:
  1465.          if (query_type == QUERY_MODIFY)
  1466.            {
  1467.             sprintf(num1,"%d",CURRENT_VIEW->current_row+1);
  1468.             item_values[1].value = num1;
  1469.             item_values[1].len = strlen(num1);
  1470.             number_variables = 1;
  1471.            }
  1472.          else
  1473.            {
  1474.             item_values[1].value = "-1";
  1475.             item_values[1].len = 2;
  1476.             sprintf(num1,"%d",CURRENT_VIEW->current_row+1);
  1477.             item_values[2].value = num1;
  1478.             item_values[2].len = strlen(num1);
  1479. #ifdef USE_VOID
  1480.             curr = (LINE *)ll_find((void *)CURRENT_FILE->first_line,get_true_line());
  1481. #else
  1482.             curr = lll_find(CURRENT_FILE->first_line,get_true_line());
  1483. #endif
  1484.             item_values[3].value = (char *)curr->line;
  1485.             item_values[3].len = curr->length;
  1486.            }
  1487.          break;
  1488. #if !defined(NOREXX)
  1489.     case ITEM_CURRENT_FUNCTION:
  1490.          if (CURRENT_VIEW->current_window != WINDOW_COMMAND
  1491.          &&  CURRENT_VIEW->focus_line == CURRENT_VIEW->current_line)
  1492.            {
  1493.             item_values[1].value = "1";
  1494.             item_values[1].len = 1;
  1495.            }
  1496.           else
  1497.            {
  1498.             item_values[1].value = "0";
  1499.             item_values[1].len = 1;
  1500.            }
  1501.          break;
  1502. #endif
  1503. #if !defined(NOREXX)
  1504.     case ITEM_DIR_FUNCTION:
  1505.          if (CURRENT_FILE->pseudo_file == PSEUDO_DIR)
  1506.            {
  1507.             item_values[1].value = "1";
  1508.             item_values[1].len = 1;
  1509.            }
  1510.          else
  1511.            {
  1512.             item_values[1].value = "0";
  1513.             item_values[1].len = 1;
  1514.            }
  1515.          break;
  1516. #endif
  1517. #if !defined(NOREXX)
  1518.     case ITEM_DIRFILEID:
  1519.          true_line = (-1L);
  1520.          if (CURRENT_FILE->pseudo_file == PSEUDO_DIR)
  1521.            {
  1522.             if (CURRENT_VIEW->current_window == WINDOW_COMMAND)
  1523.                if (CURRENT_TOF || CURRENT_BOF)
  1524.                   true_line = (-1L);
  1525.                else
  1526.                   true_line = CURRENT_VIEW->current_line;
  1527.             else
  1528.                if (FOCUS_TOF || FOCUS_BOF)
  1529.                   true_line = (-1L);
  1530.                else
  1531.                   true_line = CURRENT_VIEW->focus_line;
  1532.            }
  1533.          else
  1534.             true_line = (-1L);
  1535.          if (true_line == (-1L))
  1536.            {
  1537.             item_values[1].value = "";
  1538.             item_values[1].len = 0;
  1539.             item_values[2].value = "";
  1540.             item_values[2].len = 0;
  1541.            }
  1542.          else
  1543.            {
  1544. #ifdef USE_VOID
  1545.             curr = (LINE *)ll_find((void *)CURRENT_FILE->first_line,true_line);
  1546. #else
  1547.             curr = lll_find(CURRENT_FILE->first_line,true_line);
  1548. #endif
  1549.             item_values[1].value = (char *)dir_path;
  1550.             item_values[1].len = strlen(dir_path);
  1551.             if (curr->length < file_start)
  1552.               {
  1553.                item_values[2].value = "";
  1554.                item_values[2].len = 0;
  1555.               }
  1556.             else
  1557.               {
  1558.                item_values[2].value = (char *)curr->line+file_start;
  1559.                item_values[2].len = strlen(curr->line+file_start);
  1560.               }
  1561.            }
  1562.          break;
  1563. #endif
  1564. #if !defined(NOREXX)
  1565.     case ITEM_END_FUNCTION:
  1566.          getyx(CURRENT_WINDOW,y,x);
  1567.          if (CURRENT_VIEW->current_window == WINDOW_MAIN
  1568.          &&  (x+CURRENT_VIEW->verify_col) == rec_len)
  1569.            {
  1570.             item_values[1].value = "1";
  1571.             item_values[1].len = 1;
  1572.            }
  1573.           else
  1574.            {
  1575.             item_values[1].value = "0";
  1576.             item_values[1].len = 1;
  1577.            }
  1578.          break;
  1579. #endif
  1580.     case ITEM_EOF:
  1581.          if (CURRENT_BOF)
  1582.            {
  1583.             item_values[1].value = "ON";
  1584.             item_values[1].len = 2;
  1585.            }
  1586.           else
  1587.            {
  1588.             item_values[1].value = "OFF";
  1589.             item_values[1].len = 3;
  1590.            }
  1591.          break;
  1592. #if !defined(NOREXX)
  1593.     case ITEM_EOF_FUNCTION:
  1594.          if (FOCUS_BOF && CURRENT_VIEW->current_window != WINDOW_COMMAND)
  1595.            {
  1596.             item_values[1].value = "1";
  1597.             item_values[1].len = 1;
  1598.            }
  1599.           else
  1600.            {
  1601.             item_values[1].value = "0";
  1602.             item_values[1].len = 1;
  1603.            }
  1604.          break;
  1605. #endif
  1606.     case ITEM_EOLOUT:
  1607.          if (CURRENT_FILE->eolout == EOLOUT_LF)
  1608.            {
  1609.             item_values[1].value = "LF";
  1610.             item_values[1].len = 2;
  1611.            }
  1612.           else
  1613.            {
  1614.             item_values[1].value = "CRLF";
  1615.             item_values[1].len = 4;
  1616.            }
  1617.          break;
  1618.     case ITEM_ETMODE:
  1619.          if (extended_display_mode)
  1620.            {
  1621.             item_values[1].value = "ON";
  1622.             item_values[1].len = 2;
  1623.            }
  1624.           else
  1625.            {
  1626.             item_values[1].value = "OFF";
  1627.             item_values[1].len = 3;
  1628.            }
  1629.          break;
  1630. #if !defined(NOREXX)
  1631.     case ITEM_FIRST_FUNCTION:
  1632.          getyx(CURRENT_WINDOW,y,x);
  1633.          if (x == 0)
  1634.            {
  1635.             item_values[1].value = "1";
  1636.             item_values[1].len = 1;
  1637.            }
  1638.          else
  1639.            {
  1640.             item_values[1].value = "0";
  1641.             item_values[1].len = 1;
  1642.            }
  1643.          break;
  1644. #endif
  1645. #if !defined(NOREXX)
  1646.     case ITEM_FOCUSEOF_FUNCTION:
  1647.          if (FOCUS_BOF)
  1648.            {
  1649.             item_values[1].value = "1";
  1650.             item_values[1].len = 1;
  1651.            }
  1652.          else
  1653.            {
  1654.             item_values[1].value = "0";
  1655.             item_values[1].len = 1;
  1656.            }
  1657.          break;
  1658. #endif
  1659. #if !defined(NOREXX)
  1660.     case ITEM_FOCUSTOF_FUNCTION:
  1661.          if (FOCUS_TOF)
  1662.            {
  1663.             item_values[1].value = "1";
  1664.             item_values[1].len = 1;
  1665.            }
  1666.          else
  1667.            {
  1668.             item_values[1].value = "0";
  1669.             item_values[1].len = 1;
  1670.            }
  1671.          break;
  1672. #endif
  1673. #if !defined(NOREXX)
  1674.     case ITEM_FNAME:
  1675.          item_values[1].value = (char *)CURRENT_FILE->fname;
  1676.          item_values[1].len = strlen(CURRENT_FILE->fname);
  1677.          break;
  1678. #endif
  1679. #if !defined(NOREXX)
  1680.     case ITEM_FPATH:
  1681.          item_values[1].value = (char *)CURRENT_FILE->fpath;
  1682.          item_values[1].len = strlen(CURRENT_FILE->fpath);
  1683.          break;
  1684. #endif
  1685. #if !defined(NOREXX)
  1686.     case ITEM_FTYPE:
  1687.          x = strzreveq(CURRENT_FILE->fname,'.');
  1688.          if (x == (-1))
  1689.            {
  1690.             item_values[1].value = "";
  1691.             item_values[1].len = 0;
  1692.            }
  1693.          else
  1694.            {
  1695.             item_values[1].value = (char *)CURRENT_FILE->fname+x+1;
  1696.             item_values[1].len = strlen(CURRENT_FILE->fname+x+1);
  1697.            }
  1698.          break;
  1699. #endif
  1700. #if !defined(NOREXX)
  1701.     case ITEM_GETENV:
  1702.          if (query_type == QUERY_FUNCTION)
  1703.             tmpbuf = getenv(arg);
  1704.          else
  1705.             tmpbuf = getenv(itemargs);
  1706.          if (tmpbuf == NULL)
  1707.             item_values[1].value = "***invalid***";
  1708.          else
  1709.             item_values[1].value = tmpbuf;
  1710.          item_values[1].len = strlen(item_values[1].value);
  1711.          break;
  1712. #endif
  1713.     case ITEM_HEX:
  1714.          if (CURRENT_VIEW->hex)
  1715.            {
  1716.             item_values[1].value = "ON";
  1717.             item_values[1].len = 2;
  1718.            }
  1719.           else
  1720.            {
  1721.             item_values[1].value = "OFF";
  1722.             item_values[1].len = 3;
  1723.            }
  1724.          break;
  1725.     case ITEM_HEXDISPLAY:
  1726.          if (HEXDISPLAYx)
  1727.            {
  1728.             item_values[1].value = "ON";
  1729.             item_values[1].len = 2;
  1730.            }
  1731.           else
  1732.            {
  1733.             item_values[1].value = "OFF";
  1734.             item_values[1].len = 3;
  1735.            }
  1736.          break;
  1737.     case ITEM_IMPMACRO:
  1738.          if (CURRENT_VIEW->imp_macro)
  1739.            {
  1740.             item_values[1].value = "ON";
  1741.             item_values[1].len = 2;
  1742.            }
  1743.           else
  1744.            {
  1745.             item_values[1].value = "OFF";
  1746.             item_values[1].len = 3;
  1747.            }
  1748.          break;
  1749.     case ITEM_IMPOS:
  1750.          if (CURRENT_VIEW->imp_os)
  1751.            {
  1752.             item_values[1].value = "ON";
  1753.             item_values[1].len = 2;
  1754.            }
  1755.           else
  1756.            {
  1757.             item_values[1].value = "OFF";
  1758.             item_values[1].len = 3;
  1759.            }
  1760.          break;
  1761. #if !defined(NOREXX)
  1762.     case ITEM_INBLOCK_FUNCTION:
  1763.          bool_flag = FALSE;
  1764.          if (CURRENT_VIEW == MARK_VIEW
  1765.          &&  CURRENT_VIEW->current_window == WINDOW_MAIN)
  1766.            {
  1767.             getyx(CURRENT_WINDOW_MAIN,y,x);
  1768.             switch(MARK_VIEW->mark_type)
  1769.               {
  1770.                case M_LINE:
  1771.                     if ((CURRENT_VIEW->focus_line >= MARK_VIEW->mark_start_line)
  1772.                     &&  (CURRENT_VIEW->focus_line <= MARK_VIEW->mark_end_line))
  1773.                       bool_flag = TRUE;
  1774.                     break;
  1775.                case M_BOX:
  1776.                     if ((CURRENT_VIEW->focus_line >= MARK_VIEW->mark_start_line)
  1777.                     &&  (CURRENT_VIEW->focus_line <= MARK_VIEW->mark_end_line)
  1778.                     &&  (x + CURRENT_VIEW->verify_start >= MARK_VIEW->mark_start_col)
  1779.                     &&  (x + CURRENT_VIEW->verify_start <= MARK_VIEW->mark_end_col))
  1780.                       bool_flag = TRUE;
  1781.                     break;
  1782.                default:
  1783.                     break;
  1784.               }
  1785.            }
  1786.          if (bool_flag)
  1787.            {
  1788.             item_values[1].value = "1";
  1789.             item_values[1].len = 1;
  1790.            }
  1791.           else
  1792.            {
  1793.             item_values[1].value = "0";
  1794.             item_values[1].len = 1;
  1795.            }
  1796.          break;
  1797. #endif
  1798. #if !defined(NOREXX)
  1799.     case ITEM_INITIAL_FUNCTION:
  1800.          if (in_profile)
  1801.            {
  1802.             item_values[1].value = "1";
  1803.             item_values[1].len = 1;
  1804.            }
  1805.           else
  1806.            {
  1807.             item_values[1].value = "0";
  1808.             item_values[1].len = 1;
  1809.            }
  1810.          break;
  1811. #endif
  1812. #if !defined(NOREXX)
  1813.     case ITEM_INPREFIX_FUNCTION:
  1814.          if (CURRENT_VIEW->current_window == WINDOW_PREFIX)
  1815.            {
  1816.             item_values[1].value = "1";
  1817.             item_values[1].len = 1;
  1818.            }
  1819.           else
  1820.            {
  1821.             item_values[1].value = "0";
  1822.             item_values[1].len = 1;
  1823.            }
  1824.          break;
  1825. #endif
  1826.     case ITEM_INSERTMODE:
  1827.          if (mode_insert)
  1828.            {
  1829.             item_values[1].value = "ON";
  1830.             item_values[1].len = 2;
  1831.            }
  1832.           else
  1833.            {
  1834.             item_values[1].value = "OFF";
  1835.             item_values[1].len = 3;
  1836.            }
  1837.          break;
  1838. #if !defined(NOREXX)
  1839.     case ITEM_LASTMSG:
  1840.          item_values[1].value = (char *)last_message;
  1841.          item_values[1].len = strlen(last_message);
  1842.          break;
  1843. #endif
  1844.     case ITEM_LASTRC:
  1845.          sprintf(num1,"%d",lastrc);
  1846.          item_values[1].value = num1;
  1847.          item_values[1].len = strlen(num1);
  1848.          break;
  1849. #if !defined(NOREXX)
  1850.     case ITEM_LEFTEDGE_FUNCTION:
  1851.          getyx(CURRENT_WINDOW,y,x);
  1852.          if (CURRENT_VIEW->current_window == WINDOW_MAIN
  1853.          &&  x == 0)
  1854.            {
  1855.             item_values[1].value = "1";
  1856.             item_values[1].len = 1;
  1857.            }
  1858.           else
  1859.            {
  1860.             item_values[1].value = "0";
  1861.             item_values[1].len = 1;
  1862.            }
  1863.          break;
  1864. #endif
  1865.     case ITEM_LENGTH:
  1866. #ifdef USE_VOID
  1867.          curr = (LINE *)ll_find((void *)CURRENT_FILE->first_line,CURRENT_VIEW->current_line);
  1868. #else
  1869.          curr = lll_find(CURRENT_FILE->first_line,CURRENT_VIEW->current_line);
  1870. #endif
  1871.          sprintf(num1,"%d",curr->length);
  1872.          item_values[1].value = num1;
  1873.          item_values[1].len = strlen(num1);
  1874.          break;
  1875.     case ITEM_LINE:
  1876.          sprintf(num1,"%d",get_true_line());
  1877.          item_values[1].value = num1;
  1878.          item_values[1].len = strlen(num1);
  1879.          break;
  1880.     case ITEM_LINEND:
  1881.          if (CURRENT_VIEW->linend_status)
  1882.            {
  1883.             item_values[1].value = "ON";
  1884.             item_values[1].len = 2;
  1885.            }
  1886.           else
  1887.            {
  1888.             item_values[1].value = "OFF";
  1889.             item_values[1].len = 3;
  1890.            }
  1891.          num1[0] = CURRENT_VIEW->linend_value;
  1892.          num1[1] = '\0';
  1893.          item_values[2].value = num1;
  1894.          item_values[2].len = 1;
  1895.          break;
  1896.     case ITEM_MACROEXT:
  1897.          if (strlen(macro_suffix) == 0)
  1898.             item_values[1].value = (char *)macro_suffix;
  1899.          else
  1900.             item_values[1].value = (char *)macro_suffix+1;
  1901.          item_values[1].len = strlen(macro_suffix);
  1902.          break;
  1903.     case ITEM_MACROPATH:
  1904.          item_values[1].value = (char *)the_macro_path;
  1905.          item_values[1].len = strlen(the_macro_path);
  1906.          break;
  1907.     case ITEM_MARGINS:
  1908.          sprintf(num1,"%d",CURRENT_VIEW->margin_left);
  1909.          item_values[1].value = num1;
  1910.          item_values[1].len = strlen(num1);
  1911.          sprintf(num2,"%d",CURRENT_VIEW->margin_right);
  1912.          item_values[2].value = num2;
  1913.          item_values[2].len = strlen(num2);
  1914.          if (CURRENT_VIEW->margin_indent_offset)
  1915.             sprintf(num3,"%+d",CURRENT_VIEW->margin_indent);
  1916.          else
  1917.             sprintf(num3,"%d",CURRENT_VIEW->margin_indent);
  1918.          item_values[3].value = num3;
  1919.          item_values[3].len = strlen(num3);
  1920.          break;
  1921. #if !defined(NOREXX)
  1922.     case ITEM_MODIFIABLE_FUNCTION:
  1923.          switch(CURRENT_VIEW->current_window)
  1924.            {
  1925.             case WINDOW_MAIN:
  1926.                  if (FOCUS_TOF || FOCUS_BOF)
  1927.                     bool_flag = FALSE;
  1928.                  else
  1929.                     bool_flag = TRUE;
  1930.                  break;
  1931.             default:
  1932.                  bool_flag = TRUE;
  1933.                  break;
  1934.            }
  1935.          if (bool_flag)
  1936.            {
  1937.             item_values[1].value = "1";
  1938.             item_values[1].len = 1;
  1939.            }
  1940.           else
  1941.            {
  1942.             item_values[1].value = "0";
  1943.             item_values[1].len = 1;
  1944.            }
  1945.          break;
  1946. #endif
  1947.     case ITEM_MONITOR:
  1948. #ifdef A_COLOR
  1949.          if (colour_support)
  1950.            {
  1951.             item_values[1].value = "COLOR";
  1952.             item_values[1].len = 5;
  1953.            }
  1954.           else
  1955.            {
  1956.             item_values[1].value = "MONO";
  1957.             item_values[1].len = 4;
  1958.            }
  1959.           item_values[2].value = "COLOR";
  1960.           item_values[2].len = 5;
  1961.           break;
  1962. #else
  1963.           item_values[1].value = "MONO";
  1964.           item_values[1].len = 4;
  1965.           item_values[2].value = "MONO";
  1966.           item_values[2].len = 4;
  1967.          break;
  1968. #endif
  1969.     case ITEM_MSGMODE:
  1970.          if (CURRENT_VIEW->message_mode)
  1971.            {
  1972.             item_values[1].value = "ON";
  1973.             item_values[1].len = 2;
  1974.            }
  1975.           else
  1976.            {
  1977.             item_values[1].value = "OFF";
  1978.             item_values[1].len = 3;
  1979.            }
  1980.          break;
  1981.     case ITEM_NBFILE:
  1982.          sprintf(num1,"%d",number_of_files);
  1983.          item_values[1].value = num1;
  1984.          item_values[1].len = strlen(num1);
  1985.          break;
  1986.     case ITEM_NEWLINES:
  1987.          if (CURRENT_VIEW->newline_aligned)
  1988.            {
  1989.             item_values[1].value = "ALIGNED";
  1990.             item_values[1].len = 7;
  1991.            }
  1992.           else
  1993.            {
  1994.             item_values[1].value = "LEFT";
  1995.             item_values[1].len = 4;
  1996.            }
  1997.          break;
  1998.     case ITEM_NONDISP:
  1999.          num1[0] = NONDISPx;
  2000.          num1[1] ='\0';
  2001.          item_values[1].value = num1;
  2002.          item_values[1].len = 1;
  2003.          break;
  2004.     case ITEM_NUMBER:
  2005.          if (CURRENT_VIEW->number)
  2006.            {
  2007.             item_values[1].value = "ON";
  2008.             item_values[1].len = 2;
  2009.            }
  2010.          else
  2011.            {
  2012.             item_values[1].value = "OFF";
  2013.             item_values[1].len = 3;
  2014.            }
  2015.          break;
  2016. #if !defined(NOREXX)
  2017.     case ITEM_PENDING:
  2018.          number_variables = extract_pending(itemno,itemargs);
  2019.          break;
  2020. #endif
  2021. #if !defined(NOREXX)
  2022.     case ITEM_POINT:
  2023.          number_variables = extract_point(itemno,itemargs);
  2024.          break;
  2025. #endif
  2026.     case ITEM_PREFIX:
  2027. #if !defined(NOREXX)
  2028.          if (strcmp(itemargs,"") != 0)
  2029.            {
  2030.             number_variables = extract_prefix(itemno,itemargs);
  2031.             break;
  2032.            }
  2033. #else
  2034.          if (strcmp(itemargs,"") != 0)
  2035.            {
  2036.             display_error(2,(char *)itemargs);
  2037.             number_variables = EXTRACT_ARG_ERROR;
  2038.             break;
  2039.            }
  2040. #endif
  2041.          switch(CURRENT_VIEW->prefix)
  2042.            {
  2043.             case PREFIX_LEFT:
  2044.                  item_values[1].value = "ON";
  2045.                  item_values[1].len = 2;
  2046.                  item_values[2].value = "LEFT";
  2047.                  item_values[2].len = 4;
  2048.                  number_variables = 2;
  2049.                  break;
  2050.             case PREFIX_RIGHT:
  2051.                  item_values[1].value = "ON";
  2052.                  item_values[1].len = 2;
  2053.                  item_values[2].value = "RIGHT";
  2054.                  item_values[2].len = 5;
  2055.                  number_variables = 2;
  2056.                  break;
  2057.             default:
  2058.                  item_values[1].value = "OFF";
  2059.                  item_values[1].len = 3;
  2060.                  item_values[2].value = "";  /* this set to empty deliberately */
  2061.                  item_values[2].len = 0;
  2062.                  number_variables = 1;
  2063.                  break;
  2064.            }
  2065.          break;
  2066.     case ITEM_PRINTER:
  2067. #if defined(UNIX) || defined(OS2)
  2068.          item_values[1].value = (char *)spooler_name;
  2069.          item_values[1].len = strlen(spooler_name);
  2070. #else
  2071.          item_values[1].value = "LPT1";
  2072.          item_values[1].len = 4;
  2073. #endif
  2074.          break;
  2075.     case ITEM_REPROFILE:
  2076.          if (REPROFILEx)
  2077.            {
  2078.             item_values[1].value = "ON";
  2079.             item_values[1].len = 2;
  2080.            }
  2081.           else
  2082.            {
  2083.             item_values[1].value = "OFF";
  2084.             item_values[1].len = 3;
  2085.            }
  2086.          break;
  2087. #if !defined(NOREXX)
  2088.     case ITEM_REXXOUTPUT:
  2089.          if (CAPREXXOUTx)
  2090.            {
  2091.             item_values[1].value = "FILE";
  2092.             item_values[1].len = 4;
  2093.            }
  2094.           else
  2095.            {
  2096.             item_values[1].value = "DISPLAY";
  2097.             item_values[1].len = 7;
  2098.            }
  2099.          sprintf(num1,"%d",CAPREXXMAXx);
  2100.          item_values[2].value = num1;
  2101.          item_values[2].len = strlen(num1);
  2102.          break;
  2103. #endif
  2104. #if !defined(NOREXX)
  2105.     case ITEM_RIGHTEDGE_FUNCTION:
  2106.          getyx(CURRENT_WINDOW,y,x);
  2107.          if (CURRENT_VIEW->current_window == WINDOW_MAIN
  2108.          &&  x == getmaxx(CURRENT_WINDOW)-1)
  2109.            {
  2110.             item_values[1].value = "1";
  2111.             item_values[1].len = 1;
  2112.            }
  2113.           else
  2114.            {
  2115.             item_values[1].value = "0";
  2116.             item_values[1].len = 1;
  2117.            }
  2118.          break;
  2119. #endif
  2120.     case ITEM_SIZE:
  2121.          sprintf(num1,"%d",CURRENT_FILE->number_lines);
  2122.          item_values[1].value = num1;
  2123.          item_values[1].len = strlen(num1);
  2124.          break;
  2125. #if !defined(NOREXX)
  2126.     case ITEM_SPACECHAR_FUNCTION:
  2127.          cursor_char = (char)winch(CURRENT_WINDOW) & A_CHARTEXT;
  2128.          if (cursor_char == ' ')
  2129.            {
  2130.             item_values[1].value = "1";
  2131.             item_values[1].len = 1;
  2132.            }
  2133.           else
  2134.            {
  2135.             item_values[1].value = "0";
  2136.             item_values[1].len = 1;
  2137.            }
  2138.          break;
  2139. #endif
  2140.     case ITEM_STAY:
  2141.          if (CURRENT_VIEW->stay)
  2142.            {
  2143.             item_values[1].value = "ON";
  2144.             item_values[1].len = 2;
  2145.            }
  2146.           else
  2147.            {
  2148.             item_values[1].value = "OFF";
  2149.             item_values[1].len = 3;
  2150.            }
  2151.          break;
  2152.     case ITEM_TABKEY:
  2153.          if (tabkey_insert == 'T')
  2154.            {
  2155.             item_values[1].value = "TAB";
  2156.             item_values[1].len = 3;
  2157.            }
  2158.           else
  2159.            {
  2160.             item_values[1].value = "CHARACTER";
  2161.             item_values[1].len = 9;
  2162.            }
  2163.          if (tabkey_overwrite == 'T')
  2164.            {
  2165.             item_values[2].value = "TAB";
  2166.             item_values[2].len = 3;
  2167.            }
  2168.           else
  2169.            {
  2170.             item_values[2].value = "CHARACTER";
  2171.             item_values[2].len = 9;
  2172.            }
  2173.          break;
  2174.     case ITEM_TABS:
  2175.          sprintf(num1,"%d",CURRENT_VIEW->tabs);
  2176.          item_values[1].value = "INCR";
  2177.          item_values[1].len = 4;
  2178.          item_values[2].value = num1;
  2179.          item_values[2].len = strlen(num1);
  2180.          break;
  2181.     case ITEM_TABSIN:
  2182.          if (TABI_ONx)
  2183.            {
  2184.             item_values[1].value = "ON";
  2185.             item_values[1].len = 2;
  2186.            }
  2187.           else
  2188.            {
  2189.             item_values[1].value = "OFF";
  2190.             item_values[1].len = 3;
  2191.            }
  2192.          sprintf(num1,"%d",TABI_Nx);
  2193.          item_values[2].value = num1;
  2194.          item_values[2].len = strlen(num1);
  2195.          break;
  2196.     case ITEM_TABSOUT:
  2197.          if (TABO_ONx)
  2198.            {
  2199.             item_values[1].value = "ON";
  2200.             item_values[1].len = 2;
  2201.            }
  2202.           else
  2203.            {
  2204.             item_values[1].value = "OFF";
  2205.             item_values[1].len = 3;
  2206.            }
  2207.          sprintf(num1,"%d",TABO_Nx);
  2208.          item_values[2].value = num1;
  2209.          item_values[2].len = strlen(num1);
  2210.          break;
  2211.     case ITEM_TERMINAL:
  2212.          item_values[1].value = term_name;
  2213.          item_values[1].len = strlen(term_name);
  2214.          break;
  2215.     case ITEM_TOF:
  2216.          if (CURRENT_TOF)
  2217.            {
  2218.             item_values[1].value = "ON";
  2219.             item_values[1].len = 2;
  2220.            }
  2221.           else
  2222.            {
  2223.             item_values[1].value = "OFF";
  2224.             item_values[1].len = 3;
  2225.            }
  2226.          break;
  2227. #if !defined(NOREXX)
  2228.     case ITEM_TOF_FUNCTION:
  2229.          if (FOCUS_TOF && CURRENT_VIEW->current_window != WINDOW_COMMAND)
  2230.            {
  2231.             item_values[1].value = "1";
  2232.             item_values[1].len = 1;
  2233.            }
  2234.           else
  2235.            {
  2236.             item_values[1].value = "0";
  2237.             item_values[1].len = 1;
  2238.            }
  2239.          break;
  2240. #endif
  2241. #if !defined(NOREXX)
  2242.     case ITEM_TOPEDGE_FUNCTION:
  2243.          getyx(CURRENT_WINDOW,y,x);
  2244.          if (CURRENT_VIEW->current_window == WINDOW_MAIN
  2245.          &&  y == 0)
  2246.            {
  2247.             item_values[1].value = "1";
  2248.             item_values[1].len = 1;
  2249.            }
  2250.           else
  2251.            {
  2252.             item_values[1].value = "0";
  2253.             item_values[1].len = 1;
  2254.            }
  2255.          break;
  2256. #endif
  2257. #if !defined(NOREXX)
  2258.     case ITEM_VALID_TARGET_FUNCTION:
  2259.          if (argc != 1)   /* incorrect no of arguments - invalid */
  2260.            {
  2261.             item_values[1].value = "0";
  2262.             item_values[1].len = 1;
  2263.             break;
  2264.            }
  2265.          if (memcmpi("ALL",arg,arglen) == 0)
  2266.            {
  2267.             item_values[1].value = "ALL";
  2268.             item_values[1].len = 3;
  2269.             break;
  2270.            }
  2271.          tmpbuf = (char *)malloc(sizeof(char)*(arglen+1));
  2272.          if (tmpbuf == (char *)NULL)
  2273.            {
  2274.             item_values[1].value = "0";
  2275.             item_values[1].len = 1;
  2276.             break;
  2277.            }
  2278.          memcpy(tmpbuf,arg,arglen);
  2279.          *(tmpbuf+arglen) = '\0';
  2280.          if (in_prefix_macro)
  2281.             true_line = prefix_current_line;
  2282.          else
  2283.             true_line = get_true_line();
  2284.          num_lines = valid_target(tmpbuf,true_line);
  2285.          free(tmpbuf);
  2286.          if (num_lines == TARGET_NOT_FOUND
  2287.          ||  num_lines == TARGET_ERROR)
  2288.            {
  2289.             item_values[1].value = "0";
  2290.             item_values[1].len = 1;
  2291.             break;
  2292.            }
  2293.          sprintf(num3,"%d",num_lines);
  2294.          item_values[1].value = num3;
  2295.          item_values[1].len = strlen(num3);
  2296.          break;
  2297. #endif
  2298.     case ITEM_VERIFY:
  2299.          sprintf(num3,"%d %d",CURRENT_VIEW->verify_start,CURRENT_VIEW->verify_end);
  2300.          item_values[1].value = num3;
  2301.          item_values[1].len = strlen(num3);
  2302.          break;
  2303. #if !defined(NOREXX)
  2304.     case ITEM_VERONE_FUNCTION:
  2305.          if (CURRENT_VIEW->verify_col == 1)
  2306.            {
  2307.             item_values[1].value = "1";
  2308.             item_values[1].len = 1;
  2309.            }
  2310.           else
  2311.            {
  2312.             item_values[1].value = "0";
  2313.             item_values[1].len = 1;
  2314.            }
  2315.          break;
  2316. #endif
  2317.     case ITEM_VERSION:
  2318.          item_values[1].value = "THE";
  2319.          item_values[1].len = 3;
  2320.          item_values[2].value = (char *)the_version;
  2321.          item_values[2].len = strlen(the_version);
  2322. #if defined(DOS)
  2323.          item_values[3].value = "DOS";
  2324. #elif defined(OS2)
  2325.          item_values[3].value = "OS2";
  2326. #elif defined(UNIX)
  2327.          item_values[3].value = "UNIX";
  2328. #else
  2329.          item_values[3].value = "???";
  2330. #endif
  2331.          item_values[3].len = strlen(item_values[3].value);
  2332.          item_values[4].value = "01-Dec-93";
  2333.          item_values[4].len = strlen(item_values[4].value);
  2334.          break;
  2335.     case ITEM_WIDTH:
  2336.          sprintf(num1,"%d",max_line_length);
  2337.          item_values[1].value = num1;
  2338.          item_values[1].len = strlen(num1);
  2339.          break;
  2340.     case ITEM_WORDWRAP:
  2341.          if (CURRENT_VIEW->wordwrap)
  2342.            {
  2343.             item_values[1].value = "ON";
  2344.             item_values[1].len = 2;
  2345.            }
  2346.           else
  2347.            {
  2348.             item_values[1].value = "OFF";
  2349.             item_values[1].len = 3;
  2350.            }
  2351.          break;
  2352.     case ITEM_ZONE:
  2353.          sprintf(num1,"%d",CURRENT_VIEW->zone_start);
  2354.          item_values[1].value = num1;
  2355.          item_values[1].len = strlen(num1);
  2356.          sprintf(num2,"%d",CURRENT_VIEW->zone_end);
  2357.          item_values[2].value = num2;
  2358.          item_values[2].len = strlen(num2);
  2359.          break;
  2360.     default:
  2361.          break;
  2362.    }
  2363. /*---------------------------------------------------------------------*/
  2364. /* If an "error" condition exists, do not set any values.              */
  2365. /*---------------------------------------------------------------------*/
  2366.  if (number_variables >= 0)
  2367.    {
  2368.     switch(query_type)
  2369.       {
  2370.        case QUERY_EXTRACT:
  2371.        case QUERY_FUNCTION:
  2372.             sprintf(num0,"%d",number_variables);
  2373.             item_values[0].value = num0;
  2374.             item_values[0].len = strlen(num0);
  2375.             break;
  2376.        case QUERY_STATUS:
  2377.        case QUERY_QUERY:
  2378.        case QUERY_MODIFY:
  2379.             item_values[0].value = item[itemno].name;
  2380.             item_values[0].len = strlen(item[itemno].name);
  2381.             break;
  2382.        default:
  2383.             break;
  2384.       }
  2385.    }
  2386. #ifdef TRACE
  2387.  trace_return();
  2388. #endif
  2389.  return(number_variables);
  2390. }
  2391. #if !defined(NOREXX)
  2392. /***********************************************************************/
  2393. #ifdef PROTO
  2394. static int extract_pending(int itemno,char *params)
  2395. #else
  2396. static int extract_pending(itemno,params)
  2397. int itemno;
  2398. char *params;
  2399. #endif
  2400. /***********************************************************************/
  2401. {
  2402. /*-------------------------- external data ----------------------------*/
  2403. /*--------------------------- local data ------------------------------*/
  2404.  register int i;
  2405. #define PEN_PARAMS  4
  2406.  char *word[PEN_PARAMS+1];
  2407.  unsigned short num_params;
  2408.  int number_variables = item[itemno].number_values;
  2409.  bool find_block=FALSE;
  2410.  bool find_oldname=FALSE;
  2411.  bool valid_args = FALSE;
  2412.  int pending_idx;
  2413.  char *name;
  2414.  static char num1[7];
  2415. /*--------------------------- processing ------------------------------*/
  2416. #ifdef TRACE
  2417.  trace_function("query.c:   extract_pending");
  2418. #endif
  2419.  num_params = param_split(params,word,PEN_PARAMS,WORD_DELIMS,TEMP_PARAM);
  2420.  switch(num_params)
  2421.    {
  2422. /*---------------------------------------------------------------------*/
  2423. /* No parameters, error.                                               */
  2424. /*---------------------------------------------------------------------*/
  2425.     case 0:
  2426.            display_error(3,(char *)"");
  2427.            number_variables = EXTRACT_ARG_ERROR;
  2428.            break;
  2429. /*---------------------------------------------------------------------*/
  2430. /* 1  parameter, only name.                                            */
  2431. /*---------------------------------------------------------------------*/
  2432.     case 1:
  2433.            if (equal((char *)"block",word[0],5)
  2434.            ||  equal((char *)"oldname",word[0],7))
  2435.              {
  2436.               display_error(3,(char *)"");
  2437.               number_variables = EXTRACT_ARG_ERROR;
  2438.               break;
  2439.              }
  2440.            name = word[0];
  2441.            break;
  2442. /*---------------------------------------------------------------------*/
  2443. /* 2  parameters, BLOCK and name or OLDNAME and name.                  */
  2444. /*---------------------------------------------------------------------*/
  2445.     case 2:
  2446.            if (equal((char *)"block",word[0],5)
  2447.            &&  equal((char *)"oldname",word[1],7))
  2448.              {
  2449.               display_error(3,(char *)"");
  2450.               number_variables = EXTRACT_ARG_ERROR;
  2451.               break;
  2452.              }
  2453.            if (equal((char *)"block",word[1],5)
  2454.            &&  equal((char *)"oldname",word[0],7))
  2455.              {
  2456.               display_error(3,(char *)"");
  2457.               number_variables = EXTRACT_ARG_ERROR;
  2458.               break;
  2459.              }
  2460.            if (equal((char *)"block",word[0],5))
  2461.              {
  2462.               name = word[1];
  2463.               find_block = TRUE;
  2464.               break;
  2465.              }
  2466.            if (equal((char *)"oldname",word[0],7))
  2467.              {
  2468.               name = word[1];
  2469.               find_oldname = TRUE;
  2470.               break;
  2471.              }
  2472.            display_error(1,word[0]);
  2473.            number_variables = EXTRACT_ARG_ERROR;
  2474.            break;
  2475. /*---------------------------------------------------------------------*/
  2476. /* 3  parameters, BLOCK and OLDNAME and name.                          */
  2477. /*---------------------------------------------------------------------*/
  2478.     case 3:
  2479.            if (equal((char *)"block",word[0],5)
  2480.            &&  equal((char *)"oldname",word[1],7))
  2481.               valid_args = TRUE;
  2482.            if (equal((char *)"block",word[1],5)
  2483.            &&  equal((char *)"oldname",word[0],7))
  2484.               valid_args = TRUE;
  2485.            if (!valid_args)
  2486.              {
  2487.               display_error(1,word[0]);
  2488.               number_variables = EXTRACT_ARG_ERROR;
  2489.               break;
  2490.              }
  2491.            find_block = find_oldname = TRUE;
  2492.            name = word[2];
  2493.            break;
  2494. /*---------------------------------------------------------------------*/
  2495. /* Too many parameters, error.                                         */
  2496. /*---------------------------------------------------------------------*/
  2497.     default:
  2498.            display_error(2,(char *)"");
  2499.            number_variables = EXTRACT_ARG_ERROR;
  2500.            break;
  2501.    }
  2502. /*---------------------------------------------------------------------*/
  2503. /* If the validation of parameters is successful...                    */
  2504. /*---------------------------------------------------------------------*/
  2505.  if (number_variables >= 0)
  2506.    {
  2507. /*---------------------------------------------------------------------*/
  2508. /* No pending prefix commands, return 0.                               */
  2509. /*---------------------------------------------------------------------*/
  2510.     if (CURRENT_VIEW->prefix_command_index == 0)
  2511.        number_variables = 0;
  2512.     else
  2513. /*---------------------------------------------------------------------*/
  2514. /* Have to search each pending prefix command...                       */
  2515. /*---------------------------------------------------------------------*/
  2516.       {
  2517.        pending_idx = (-1);
  2518. /*---------------------------------------------------------------------*/
  2519. /* If we are to look for OLDNAME, find a synonym for it if one exists..*/
  2520. /*---------------------------------------------------------------------*/
  2521.        if (find_oldname)
  2522.           name = find_prefix_oldname(name);
  2523. /*---------------------------------------------------------------------*/
  2524. /* For each pending prefix command...                                  */
  2525. /*---------------------------------------------------------------------*/
  2526.        for (i=0;i<CURRENT_VIEW->prefix_command_index;i++)
  2527.          {
  2528. /*---------------------------------------------------------------------*/
  2529. /* If we want to match on any name...                                  */
  2530. /*---------------------------------------------------------------------*/
  2531.           if (strcmp(name,"*") == 0)
  2532.             {
  2533. /*---------------------------------------------------------------------*/
  2534. /* Are we matching on any BLOCK command...                             */
  2535. /*---------------------------------------------------------------------*/
  2536.              if (find_block)
  2537.                {
  2538.                 if (CURRENT_VIEW->ppc[i].ppc_block_command)
  2539.                   {
  2540. /*---------------------------------------------------------------------*/
  2541. /* We have found the first BLOCK command with any name.                */
  2542. /*---------------------------------------------------------------------*/
  2543.                    pending_idx = i;
  2544.                    break;
  2545.                   }
  2546.                 else
  2547. /*---------------------------------------------------------------------*/
  2548. /* Go back and look for another...                                     */
  2549. /*---------------------------------------------------------------------*/
  2550.                    continue;
  2551.                }
  2552.              else
  2553.                {
  2554. /*---------------------------------------------------------------------*/
  2555. /* We have found the first command with any name.                      */
  2556. /*---------------------------------------------------------------------*/
  2557.                 pending_idx = i;
  2558.                 break;
  2559.                }
  2560.             }
  2561. /*---------------------------------------------------------------------*/
  2562. /* We want to find a specific command...                               */
  2563. /*---------------------------------------------------------------------*/
  2564.           if (strcmp(CURRENT_VIEW->ppc[i].ppc_command,name) == 0)
  2565.             {
  2566. /*---------------------------------------------------------------------*/
  2567. /* Are we looking for a specific BLOCK command...                      */
  2568. /*---------------------------------------------------------------------*/
  2569.              if (find_block)
  2570.                {
  2571.                 if (CURRENT_VIEW->ppc[i].ppc_block_command)
  2572.                   {
  2573. /*---------------------------------------------------------------------*/
  2574. /* We have found the first specific BLOCK command.                     */
  2575. /*---------------------------------------------------------------------*/
  2576.                    pending_idx = i;
  2577.                    break;
  2578.                   }
  2579.                }
  2580.              else
  2581.                {
  2582. /*---------------------------------------------------------------------*/
  2583. /* We have found the first specific command.                           */
  2584. /*---------------------------------------------------------------------*/
  2585.                 pending_idx = i;
  2586.                 break;
  2587.                }
  2588.             }
  2589.          }
  2590. /*---------------------------------------------------------------------*/
  2591. /* Did we find a matching pending prefix command ?                     */
  2592. /*---------------------------------------------------------------------*/
  2593.        if (pending_idx == (-1))
  2594.           number_variables = 0;
  2595.        else
  2596.          {
  2597. /*---------------------------------------------------------------------*/
  2598. /* Yes we did. Set all of the REXX variables to the correct values...  */
  2599. /*---------------------------------------------------------------------*/
  2600.           sprintf(num1,"%d",CURRENT_VIEW->ppc[pending_idx].ppc_line_number);
  2601.           item_values[1].value = num1;
  2602.           item_values[1].len = strlen(num1);
  2603.           item_values[2].value = CURRENT_VIEW->ppc[pending_idx].ppc_command;
  2604.           item_values[2].len = strlen(item_values[2].value);
  2605.           item_values[3].value = find_prefix_synonym(CURRENT_VIEW->ppc[pending_idx].ppc_command);
  2606.           item_values[3].len = strlen(item_values[2].value);
  2607.           if (CURRENT_VIEW->ppc[pending_idx].ppc_block_command)
  2608.              item_values[4].value = "BLOCK";
  2609.           else
  2610.              item_values[4].value = "";
  2611.           item_values[4].len = strlen(item_values[4].value);
  2612.          }
  2613.       }
  2614.    }
  2615. #ifdef TRACE
  2616.  trace_return();
  2617. #endif
  2618.  return(number_variables);
  2619. }
  2620. /***********************************************************************/
  2621. #ifdef PROTO
  2622. static int extract_point(int itemno,char *params)
  2623. #else
  2624. static int extract_point(itemno,params)
  2625. int itemno;
  2626. char *params;
  2627. #endif
  2628. /***********************************************************************/
  2629. {
  2630. /*-------------------------- external data ----------------------------*/
  2631. /*--------------------------- local data ------------------------------*/
  2632.  register int i;
  2633.  int number_variables = item[itemno].number_values;
  2634.  static char num4[15];
  2635.  LINE *curr;
  2636.  long true_line;
  2637.  int rc;
  2638. /*--------------------------- processing ------------------------------*/
  2639. #ifdef TRACE
  2640.  trace_function("query.c:   extract_point");
  2641. #endif
  2642.  if (strcmp(params,"") == 0) /* get name for focus line only */
  2643.    {
  2644.     true_line = get_true_line();
  2645.     curr = lll_find(CURRENT_FILE->first_line,true_line);
  2646.     if (curr->name == NULL)  /* line not named */
  2647.        number_variables = 0;
  2648.     else
  2649.       {
  2650.        sprintf(num4,"%d %s",true_line,curr->name);
  2651.        item_values[1].value = num4;
  2652.        item_values[1].len = strlen(num4);
  2653.        number_variables = 1;
  2654.       }
  2655.    }
  2656.  else
  2657.    {
  2658.     if (strcmp(params,"*") != 0)     /* argument must be "*" */
  2659.       {
  2660.        display_error(1,(char *)params);
  2661.        number_variables = EXTRACT_ARG_ERROR;
  2662.       }
  2663.     else
  2664.       {
  2665.        curr = CURRENT_FILE->first_line;
  2666.        for(true_line=0,i=0;curr != NULL;true_line++)
  2667.          {
  2668.           if (curr->name != NULL)  /* line is named */
  2669.             {
  2670.              sprintf(num4,"%d %s",true_line,curr->name);
  2671.              rc = set_rexx_variable(item[itemno].name,num4,++i);
  2672.              if (rc == RC_SYSTEM_ERROR)
  2673.                {
  2674.                 display_error(54,(char *)"");
  2675. #ifdef TRACE
  2676.                 trace_return();
  2677. #endif
  2678.                 return(EXTRACT_ARG_ERROR);
  2679.                }
  2680.             }
  2681.           curr = curr->next;
  2682.          }
  2683.        sprintf(num4,"%d",i);
  2684.        rc = set_rexx_variable(item[itemno].name,num4,0);
  2685.        if (rc == RC_SYSTEM_ERROR)
  2686.          {
  2687.           display_error(54,(char *)"");
  2688.           number_variables = EXTRACT_ARG_ERROR;
  2689.          }
  2690.        else
  2691.           number_variables = EXTRACT_VARIABLES_SET;
  2692.       }
  2693.    }
  2694. #ifdef TRACE
  2695.  trace_return();
  2696. #endif
  2697.  return(number_variables);
  2698. }
  2699. /***********************************************************************/
  2700. #ifdef PROTO
  2701. static int extract_prefix(int itemno,char *params)
  2702. #else
  2703. static int extract_prefix(itemno,params)
  2704. int itemno;
  2705. char *params;
  2706. #endif
  2707. /***********************************************************************/
  2708. {
  2709. /*-------------------------- external data ----------------------------*/
  2710.  extern LINE *first_prefix_synonym;
  2711. /*--------------------------- local data ------------------------------*/
  2712.  register int i;
  2713. #define PRE_PARAMS  3
  2714.  char *word[PRE_PARAMS+1];
  2715.  unsigned short num_params;
  2716.  int number_variables = item[itemno].number_values;
  2717.  static char num4[15];
  2718.  LINE *curr;
  2719.  int rc;
  2720.  char *tmpbuf;
  2721. /*--------------------------- processing ------------------------------*/
  2722. #ifdef TRACE
  2723.  trace_function("query.c:   extract_prefix");
  2724. #endif
  2725.  num_params = param_split(params,word,PRE_PARAMS,WORD_DELIMS,TEMP_PARAM);
  2726.  switch(num_params)
  2727.    {
  2728. /*---------------------------------------------------------------------*/
  2729. /* None or 1 parameters, error.                                        */
  2730. /*---------------------------------------------------------------------*/
  2731.     case 0:
  2732.     case 1:
  2733.            display_error(3,(char *)"");
  2734.            number_variables = EXTRACT_ARG_ERROR;
  2735.            break;
  2736. /*---------------------------------------------------------------------*/
  2737. /* 2  parameters, Synonym and name.                                    */
  2738. /*---------------------------------------------------------------------*/
  2739.     case 2:
  2740.            if (!equal((char *)"synonym",word[0],1))
  2741.              {
  2742.               display_error(13,(char *)"");
  2743.               number_variables = EXTRACT_ARG_ERROR;
  2744.               break;
  2745.              }
  2746.            break;
  2747. /*---------------------------------------------------------------------*/
  2748. /* Too many parameters, error.                                         */
  2749. /*---------------------------------------------------------------------*/
  2750.     default:
  2751.            display_error(2,(char *)"");
  2752.            number_variables = EXTRACT_ARG_ERROR;
  2753.            break;
  2754.    }
  2755. /*---------------------------------------------------------------------*/
  2756. /* If the validation of parameters is successful...                    */
  2757. /*---------------------------------------------------------------------*/
  2758.  if (number_variables >= 0)
  2759.    {
  2760.     if (strcmp(word[1],"*") == 0)
  2761. /*---------------------------------------------------------------------*/
  2762. /* Get oldname for all synonyms...                                     */
  2763. /*---------------------------------------------------------------------*/
  2764.       {
  2765.        curr = first_prefix_synonym;
  2766.        i = 0;
  2767.        while(curr != NULL)
  2768.          {
  2769.           tmpbuf = (char *)malloc(sizeof(char)*(strlen(curr->name)+strlen(curr->line)+1));
  2770.           if (tmpbuf == (char *)NULL)
  2771.             {
  2772.              display_error(30,(char *)"");
  2773. #ifdef TRACE
  2774.              trace_return();
  2775. #endif
  2776.              return(EXTRACT_ARG_ERROR);
  2777.             }
  2778.           strcpy(tmpbuf,curr->name);
  2779.           strcat(tmpbuf," ");
  2780.           strcat(tmpbuf,curr->line);
  2781.           rc = set_rexx_variable(item[itemno].name,tmpbuf,++i);
  2782.           free(tmpbuf);
  2783.           if (rc == RC_SYSTEM_ERROR)
  2784.             {
  2785.              display_error(54,(char *)"");
  2786. #ifdef TRACE
  2787.              trace_return();
  2788. #endif
  2789.              return(EXTRACT_ARG_ERROR);
  2790.             }
  2791.           curr = curr->next;
  2792.          }
  2793.        sprintf(num4,"%d",i);
  2794.        rc = set_rexx_variable(item[itemno].name,num4,0);
  2795.        if (rc == RC_SYSTEM_ERROR)
  2796.          {
  2797.           display_error(54,(char *)"");
  2798.           number_variables = EXTRACT_ARG_ERROR;
  2799.          }
  2800.        else
  2801.           number_variables = EXTRACT_VARIABLES_SET;
  2802.       }
  2803.     else
  2804. /*---------------------------------------------------------------------*/
  2805. /* Get oldname for named synonym...                                    */
  2806. /*---------------------------------------------------------------------*/
  2807.       {
  2808.        item_values[1].value = find_prefix_synonym(word[1]);
  2809.        item_values[1].len = strlen(item_values[1].value);
  2810.        number_variables = 1;
  2811.       }
  2812.  }
  2813. #ifdef TRACE
  2814.  trace_return();
  2815. #endif
  2816.  return(number_variables);
  2817. }
  2818. #endif
  2819.