home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 October / Chip_2001-10_cd1.bin / zkuste / delphi / kompon / d123456 / CHEMPLOT.ZIP / TPlot / Parser.pas < prev    next >
Pascal/Delphi Source File  |  2001-07-24  |  21KB  |  651 lines

  1. unit Parser;
  2.  
  3. {$I Plot.inc}
  4.  
  5. {-----------------------------------------------------------------------------
  6. The contents of this file are subject to the Q Public License
  7. ("QPL"); you may not use this file except in compliance
  8. with the QPL. You may obtain a copy of the QPL from 
  9. the file QPL.html in this distribution, derived from:
  10.  
  11. http://www.trolltech.com/products/download/freelicense/license.html
  12.  
  13. The QPL prohibits development of proprietary software.
  14. There is a Professional Version of this software available for this. 
  15. Contact sales@chemware.hypermart.net for more information.
  16.  
  17. Software distributed under the QPL is distributed on an "AS IS" basis,
  18. WITHOUT WARRANTY OF ANY KIND, either expressed or implied. See the QPL for
  19. the specific language governing rights and limitations under the QPL.
  20.  
  21. The Original Code is: Parser.pas, released 12 September 2000.
  22.  
  23. The Initial Developer of the Original Code is Mat Ballard.
  24. Portions created by Mat Ballard are Copyright (C) 1999 Mat Ballard.
  25. Portions created by Microsoft are Copyright (C) 1998, 1999 Microsoft Corp.
  26. All Rights Reserved.
  27.  
  28. Contributor(s): Mat Ballard                 e-mail: mat.ballard@chemware.hypermart.net.
  29.  
  30. Last Modified: 04/18/2001
  31. Current Version: 2.00
  32.  
  33. You may retrieve the latest version of this file from:
  34.  
  35.         http://Chemware.hypermart.net/
  36.  
  37. This work was created with the Project JEDI VCL guidelines:
  38.  
  39.         http://www.delphi-jedi.org/Jedi:VCLVCL
  40.  
  41. in mind. 
  42.  
  43. Purpose:
  44. To allow users to paste or import complex data into TPlot.
  45.  
  46. Known Issues:
  47. -----------------------------------------------------------------------------}
  48.  
  49. interface
  50.  
  51. uses
  52.   Classes, SysUtils,
  53. {$IFDEF WINDOWS}
  54.   WinTypes, WinProcs,
  55.   Buttons, ComCtrls, Controls, ExtCtrls, Forms, Graphics, Grids, StdCtrls,
  56. {$ENDIF}
  57. {$IFDEF WIN32}
  58.   Windows,
  59.   Buttons, ComCtrls, Controls, ExtCtrls, Forms, Graphics, Grids, StdCtrls,
  60. {$ENDIF}
  61. {$IFDEF LINUX}
  62.   QTypes, Types,
  63.   QButtons, QComCtrls, QControls, QExtCtrls, QForms, QGraphics, QGrids, QStdCtrls,
  64. {$ENDIF}
  65.   Misc, PlotDefs;
  66.  
  67. type
  68.   TDelimiter = (dlNone, dlTab, dlComma, dlSpace, dlColon, dlSemiColon,
  69.                 dlLineFeed, dlOwn);
  70.  
  71. const
  72.   COLUMN_NOS = 0;
  73.   SERIES_NAMES = 1;
  74.   FIRST_LINE_OF_DATA = 2;
  75.   X_OR_Y_OR_Z = 3;
  76.   DEPENDS_ON_X = 4;
  77.   Z_DATA_LINE = 5;
  78.  
  79.   {Delimiters: array[TDelimiter] of string =
  80.     ('', #9, ',', ' ', ';', ':', #10, 'Type your own');}
  81.   DelimiterNames: array[TDelimiter] of string =
  82.     (sNone, sTab, sComma, sSpace, sColon, sSemiColon, sLineFeed, sTypeYourOwn);
  83.  
  84. type
  85.   TColumnType = (ctIgnore, ctX, ctY);
  86.  
  87.   TSeriesInfo = Record       {The series are 0, 1, 2}
  88.     Index: Integer;          {What is the Index of this series of data in the SeriesList ?}
  89.     XCol: Integer;           {in which column is this series' X data ?}
  90.     XTextCol: Integer;       {in which column is this series' X STRING data, if any ?}
  91.     YCol: Integer;           {in which column is this series' Y data ?}
  92.     XSeriesIndex: Integer;   {what is the index of the series that contains the X Data in the SeriesList ?}
  93.     XValue: Single;          {the X Value, after a string conversion}
  94.     YValue: Single;          {the Y Value, after a string conversion}
  95.   end;
  96.  
  97. {A TSeriesInfoArray is never declared directly - instead, it is used as a
  98.  template for a dynamic array}
  99.   TSeriesInfoArray = array[0..1023] of TSeriesInfo;
  100.   pSeriesInfoArray = ^TSeriesInfoArray;
  101.  
  102.   TParserForm = class(TForm)
  103.     DataListBox: TListBox;
  104.     DelimiterLabel: TLabel;
  105.     DelimiterComboBox: TComboBox;
  106.     LineEdit: TEdit;
  107.     SetGroupBox: TGroupBox;
  108.     SeriesNamesButton: TButton;
  109.     FirstLineOfDataButton: TButton;
  110.     HelpBitBtn: TBitBtn;
  111.     BitBtn2: TBitBtn;
  112.     OKBitBtn: TBitBtn;
  113.     InfoGrid: TStringGrid;
  114.     PickXDataComboBox: TComboBox;
  115.     ZDataLineButton: TButton;
  116.     NoSeriesLabel: TLabel;
  117.     ExpandBitBtn: TBitBtn;
  118.     Timer1: TTimer;
  119.     InstructionsLabel: TLabel;
  120.     procedure FormCreate(Sender: TObject);
  121.     procedure DataListBoxClick(Sender: TObject);
  122.     procedure FirstLineOfDataButtonClick(Sender: TObject);
  123.     procedure SeriesNamesButtonClick(Sender: TObject);
  124.     procedure InfoGridClick(Sender: TObject);
  125.     procedure PickXDataComboBoxClick(Sender: TObject);
  126.     procedure HelpBitBtnClick(Sender: TObject);
  127.     procedure ZDataLineButtonClick(Sender: TObject);
  128.     procedure FormResize(Sender: TObject);
  129.     procedure ExpandBitBtnClick(Sender: TObject);
  130.     procedure Timer1Timer(Sender: TObject);
  131.   private
  132.     OriginalHeight: Integer;
  133.     InstructionIndex: Integer;
  134.     
  135.     procedure CheckDelimiter;
  136.     procedure CalculateNoSeries;
  137.   public
  138. {NB: Delimiters have to be public, so it cannot be a const array.}  
  139.     Delimiters: array[TDelimiter] of String;
  140.     {DelimiterNames: array[TDelimiter] of String;}
  141.     TheDelimiter: TDelimiter;
  142.     TheFirstDataLine: Integer;
  143.     TheSeriesNamesLine: Integer;
  144.     TheSeriesUnitsLine: Integer;
  145.     TheZDataLine: Integer;
  146.     NumberOfSeries: Integer;
  147.     TheCol, TheRow: Integer;
  148.     XDataPresent: Boolean;
  149.  
  150. {$IFNDEF LANG_ENGLISH}
  151.     procedure DoCaptionsFromResource;
  152. {$ENDIF}
  153.     procedure DoHintsFromResource;
  154.   end;
  155.  
  156. var
  157.   ParserForm: TParserForm;
  158.  
  159. implementation
  160.  
  161. {$R *.dfm}
  162.  
  163. const
  164.   Instructions: array[0..6] of string =
  165.    (sInstruction1,
  166.     sInstruction2,
  167.     sInstruction3,
  168.     sInstruction4,
  169.     sInstruction5,
  170.     sInstruction6,
  171.     sInstruction7);
  172.  
  173.   {Delimiters[dlNone] := '';
  174.   DelimiterNames[dlNone] := 'None';
  175. Tabs come from spreadsheet / table data from the clipboard:
  176.   Delimiters[dlTab] := #9;
  177.   DelimiterNames[dlTab] := 'Tab   ->';
  178. Commas come from disk data:
  179.   Delimiters[dlComma] := ',';
  180.   DelimiterNames[dlComma] := 'Comma  ,';
  181.   Delimiters[dlSpace] := ' ';
  182.   DelimiterNames[dlSpace] := 'Space   ';
  183.   Delimiters[dlColon] := ';';
  184.   DelimiterNames[dlColon] := 'Colon  ;';
  185.   Delimiters[dlSemicolon] := #58;
  186.   DelimiterNames[dlSemicolon] := 'Semicolon  :';
  187.   Delimiters[dlLinefeed] := #10;
  188.   DelimiterNames[dlLinefeed] := 'Line Feed   ┐';
  189.   Delimiters[dlOwn] := 'Type your own';
  190.   DelimiterNames[dlOwn] := 'Type your own';}
  191.  
  192.  
  193. {------------------------------------------------------------------------------
  194.     Procedure: TParserForm.FormCreate
  195.   Description: standard FormCreate procedure
  196.        Author: Mat Ballard
  197.  Date created: 04/25/2000
  198. Date modified: 04/09/2001 by Mat Ballard
  199.       Purpose: sets the position, the Delimiters and their names, and putsw headings on the stringgrid
  200.  Known Issues:
  201.  ------------------------------------------------------------------------------}
  202. procedure TParserForm.FormCreate(Sender: TObject);
  203. var
  204.   iDelimiter: TDelimiter;
  205. begin
  206. {$IFNDEF LANG_ENGLISH}
  207.   DoCaptionsFromResource;
  208. {$ENDIF}
  209.   DoHintsFromResource;
  210. {$IFDEF MSWINDOWS}
  211.   Self.BorderStyle := bsSizeable;
  212. {$ENDIF}
  213. {$IFDEF LINUX}
  214.   Self.BorderStyle := fbsSizeable;
  215. {$ENDIF}
  216.   Self.Scaled := FALSE;
  217.   Self.HorzScrollBar.Visible := FALSE;
  218.   Self.VertScrollBar.Visible := FALSE;
  219.  
  220.   Self.Left := 5;
  221.   Self.Top := 10;
  222.   OriginalHeight := OKBitBtn.Top + 2 * OKBitBtn.Height;
  223.   Self.ClientWidth := DataListBox.Left + DataListBox.Width + DataListBox.Left;
  224.   Self.ClientHeight := OriginalHeight;
  225.  
  226.   TheZDataLine := -1;
  227.   TheFirstDataLine := -1;
  228.   TheSeriesNamesLine := -1;
  229.   TheSeriesUnitsLine := -1;
  230.   XDataPresent := TRUE;
  231.  
  232.   InstructionIndex := 0;
  233.   InstructionsLabel.Caption := Instructions[InstructionIndex];
  234.  
  235.   Delimiters[dlNone] := '';
  236. {Tabs come from spreadsheet / table data from the clipboard:}
  237.   Delimiters[dlTab] := #9;
  238. {Commas come from disk data:}
  239.   Delimiters[dlComma] := ',';
  240.   Delimiters[dlSpace] := ' ';
  241.   Delimiters[dlColon] := ';';
  242.   Delimiters[dlSemicolon] := ':';
  243.   Delimiters[dlLinefeed] := #10;
  244.   Delimiters[dlOwn] := sTypeYourOwn;
  245.   for iDelimiter := dlNone to dlOwn do
  246.   begin
  247.     DelimiterComboBox.Items.Add(DelimiterNames[iDelimiter]);
  248.   end;
  249.  
  250.   with InfoGrid do
  251.   begin
  252.     Cells[0, COLUMN_NOS] := sColumn + ' ' + sNumber;
  253.     Cells[0, SERIES_NAMES] := sSeries + ' ' + sNames;
  254.     Cells[0, FIRST_LINE_OF_DATA] := sFirst + ' ' + sLine + sOf + sData;
  255.     Cells[0, X_OR_Y_OR_Z] := 'X, Y' + sOr + 'Z ' + sData;
  256.     Cells[0, DEPENDS_ON_X] := sData + strIn + sColumn + ' #:';
  257.     Cells[0, Z_DATA_LINE] := 'Z ' + sData;
  258.     DefaultColWidth := 80;
  259.     ColWidths[0] := 150;
  260.   end;
  261. end;
  262.  
  263. {------------------------------------------------------------------------------
  264.     Procedure: TParserForm.DoCaptionsFromResource
  265.   Description: standard loading of labels from resources
  266.        Author: Mat Ballard
  267.  Date created: 06/25/2001
  268. Date modified: 06/25/2001 by Mat Ballard
  269.       Purpose: display in different languages
  270.  Known Issues:
  271.  ------------------------------------------------------------------------------}
  272. {$IFNDEF LANG_ENGLISH}
  273. procedure TParserForm.DoCaptionsFromResource;
  274. begin
  275.   Self.Caption := sParser;
  276.   DelimiterLabel.Caption := sDelimiter;
  277.   SetGroupBox.Caption := sSetGroupBox;
  278.   SeriesNamesButton.Caption := sSeries + ' ' + sNames;
  279.   FirstLineOfDataButton.Caption := sFirstLine;
  280.   ZDataLineButton.Caption := sZDataLine;
  281.   NoSeriesLabel.Caption := sNoSeriesFoundYet;
  282.   ExpandBitBtn.Caption := sExpand;
  283. end;
  284. {$ENDIF}
  285.  
  286. {------------------------------------------------------------------------------
  287.     Procedure: TParserForm.DoHintsFromResource
  288.   Description: standard loading of hints from resources
  289.        Author: Mat Ballard
  290.  Date created: 06/25/2001
  291. Date modified: 06/25/2001 by Mat Ballard
  292.       Purpose: display in different languages
  293.  Known Issues:
  294.  ------------------------------------------------------------------------------}
  295. procedure TParserForm.DoHintsFromResource;
  296. begin
  297.   DelimiterComboBox.Hint := sDelimiterComboBoxHint;
  298.   SeriesNamesButton.Hint := sSeriesNamesButtonHint;
  299.   FirstLineOfDataButton.Hint := sFirstLineOfDataButtonHint;
  300.   ZDataLineButton.Hint := sZDataLineButtonHint;
  301.   InfoGrid.Hint := sInfoGridHint;
  302.   PickXDataComboBox.Hint := sPickXDataComboBoxHint;
  303.   ExpandBitBtn.Hint := sExpandBitBtnHint;
  304. end;
  305.  
  306.  
  307. {------------------------------------------------------------------------------
  308.     Procedure: TParserForm.DataListBoxClick
  309.   Description: responds to user selection of a line
  310.        Author: Mat Ballard
  311.  Date created: 04/25/2000
  312. Date modified: 04/25/2000 by Mat Ballard
  313.       Purpose: places the selected line into the Edit box, and checks it for Delimiters
  314.  Known Issues:
  315.  ------------------------------------------------------------------------------}
  316. procedure TParserForm.DataListBoxClick(Sender: TObject);
  317. begin
  318.   LineEdit.Text := DataListBox.Items[DataListBox.ItemIndex];
  319.   CheckDelimiter;
  320. end;
  321.  
  322. {------------------------------------------------------------------------------
  323.     Procedure: TParserForm.CheckDelimiter
  324.   Description: determines the Delimiter in a line
  325.        Author: Mat Ballard
  326.  Date created: 04/25/2000
  327. Date modified: 04/25/2000 by Mat Ballard
  328.       Purpose: sets Delimiter
  329.  Known Issues:
  330.  ------------------------------------------------------------------------------}
  331. procedure TParserForm.CheckDelimiter;
  332. var
  333.   iDelimiter: TDelimiter;
  334. begin
  335.   TheDelimiter := dlNone;
  336.   for iDelimiter := dlTab to dlLineFeed do
  337.   begin
  338.     if (Pos(Delimiters[iDelimiter], LineEdit.Text) > 0) then
  339.     begin
  340.       TheDelimiter := iDelimiter;
  341.       break;
  342.     end;
  343.   end;
  344.   DelimiterComboBox.ItemIndex := Ord(TheDelimiter);
  345. end;
  346.  
  347. {------------------------------------------------------------------------------
  348.     Procedure: TParserForm.CalculateNoSeries
  349.   Description: Calculates the number of Series (Y columns)
  350.        Author: Mat Ballard
  351.  Date created: 04/09/2001
  352. Date modified: 04/09/2001 by Mat Ballard
  353.       Purpose: see Description
  354.  Known Issues:
  355.  ------------------------------------------------------------------------------}
  356. procedure TParserForm.CalculateNoSeries;
  357. var
  358.   iColumn: Integer;
  359. begin
  360.   NumberOfSeries := 0;
  361.   for iColumn := 2 to InfoGrid.ColCount-1 do
  362.   begin
  363.     if (InfoGrid.Cells[iColumn, X_OR_Y_OR_Z] = 'Y') then
  364.       Inc(NumberOfSeries);
  365.   end;
  366.   NoSeriesLabel.Caption := Format(sThereSeemsToBe + ' %d ' + sSeries, [NumberOfSeries]);
  367. end;
  368.  
  369. {------------------------------------------------------------------------------
  370.     Procedure: TParserForm.FirstLineOfDataButtonClick
  371.   Description: responds to the selection of the first line of data
  372.        Author: Mat Ballard
  373.  Date created: 04/25/2000
  374. Date modified: 04/25/2000 by Mat Ballard
  375.       Purpose: fills the InfoGrid cells with the parsed line
  376.  Known Issues:
  377.  ------------------------------------------------------------------------------}
  378. procedure TParserForm.FirstLineOfDataButtonClick(Sender: TObject);
  379. var
  380.   TheLine: String;
  381.   iColumn: Integer;
  382. begin
  383.   ZDataLineButton.Enabled := TRUE;
  384.   
  385.   TheFirstDataLine := DataListBox.ItemIndex;
  386.   TheLine := DataListBox.Items[DataListBox.ItemIndex];
  387.   iColumn := 1;
  388.   {InfoGrid.ColCount := 3;}
  389.   while (Length(TheLine) > 0) do
  390.   begin
  391.     if (InfoGrid.ColCount <= iColumn) then
  392.       InfoGrid.ColCount := iColumn+1;
  393.     InfoGrid.Cells[iColumn, FIRST_LINE_OF_DATA] :=
  394.       GetWord(TheLine, Delimiters[TheDelimiter]);
  395.     Inc(iColumn);
  396.   end;
  397.  
  398.   for iColumn := 1 to InfoGrid.ColCount-1 do
  399.   begin
  400.     InfoGrid.Cells[iColumn, COLUMN_NOS] := IntToStr(iColumn);
  401.   end;
  402.  
  403.   InfoGrid.Cells[1, X_OR_Y_OR_Z] := 'X';
  404.   for iColumn := 2 to InfoGrid.ColCount-1 do
  405.   begin
  406.     InfoGrid.Cells[iColumn, X_OR_Y_OR_Z] := 'Y';
  407.   end;
  408.  
  409.   InfoGrid.Cells[1, DEPENDS_ON_X] := '';
  410.   for iColumn := 2 to InfoGrid.ColCount-1 do
  411.   begin
  412.     InfoGrid.Cells[iColumn, DEPENDS_ON_X] := '1';
  413.   end;
  414.  
  415.   OKBitBtn.Enabled := TRUE;
  416.  
  417.   CalculateNoSeries;  
  418. end;
  419.  
  420. {------------------------------------------------------------------------------
  421.     Procedure: TParserForm.SeriesNamesButtonClick
  422.   Description: responds to the selection of the Series names
  423.        Author: Mat Ballard
  424.  Date created: 04/25/2000
  425. Date modified: 04/25/2000 by Mat Ballard
  426.       Purpose: fills the InfoGrid Series Names row with the parsed line
  427.  Known Issues:
  428.  ------------------------------------------------------------------------------}
  429. procedure TParserForm.SeriesNamesButtonClick(Sender: TObject);
  430. var
  431.   TheLine: String;
  432.   iColumn: Integer;
  433. begin
  434.   TheSeriesNamesLine := DataListBox.ItemIndex;
  435.   TheLine := DataListBox.Items[DataListBox.ItemIndex];
  436.   iColumn := 1;
  437.   while (Length(TheLine) > 0) do
  438.   begin
  439.     if (InfoGrid.ColCount <= iColumn) then
  440.       InfoGrid.ColCount := iColumn+1;
  441.     InfoGrid.Cells[iColumn, SERIES_NAMES] :=
  442.       GetWord(TheLine, Delimiters[TheDelimiter]);
  443.     Inc(iColumn);
  444.   end;
  445.   InfoGrid.ColCount := iColumn;
  446.  
  447.   for iColumn := 1 to InfoGrid.ColCount-1 do
  448.   begin
  449.     InfoGrid.Cells[iColumn, COLUMN_NOS] := IntToStr(iColumn);
  450.   end;
  451. end;
  452.  
  453. {------------------------------------------------------------------------------
  454.     Procedure: TParserForm.InfoGridClick
  455.   Description: responds to the selection of a cell in the StringGrid
  456.        Author: Mat Ballard
  457.  Date created: 04/25/2000
  458. Date modified: 04/25/2000 by Mat Ballard
  459.       Purpose: sets the InfoGrid options, contents of some cells, and PickXDataComboBox position and visibility
  460.  Known Issues:
  461.  ------------------------------------------------------------------------------}
  462. procedure TParserForm.InfoGridClick(Sender: TObject);
  463. var
  464.   Rect: TRect;
  465.   iColumn, iXColumn: Integer;
  466.   LocalXDataPresent: Boolean;
  467.   TheText: String;
  468. begin
  469.   with InfoGrid do
  470.   begin
  471.     if (((Row = SERIES_NAMES) or
  472.          (Row = Z_DATA_LINE)) and
  473.          (Col > 0)) then
  474.     begin
  475.       Options := [goFixedVertLine,goFixedHorzLine,goVertLine,goHorzLine,
  476.         goDrawFocusSelected,goColSizing, goEditing];
  477.     end
  478.     else
  479.     begin
  480.       Options := [goFixedVertLine,goFixedHorzLine,goVertLine,goHorzLine,
  481.         goDrawFocusSelected,goColSizing];
  482.     end;
  483.  
  484.     if ((Row = X_OR_Y_OR_Z) and (Col >= 1)) then
  485.     begin
  486.       if (Cells[Col, Row] = 'X') then
  487.       begin
  488.         Cells[Col, Row] := 'XTEXT';
  489.         Cells[Col, Row + 1] := '';
  490.         Cells[Col, Z_DATA_LINE] := '';
  491.       end
  492.       else if (Cells[Col, Row] = 'XTEXT') then
  493.       begin
  494.         Cells[Col, Row] := 'Y';
  495.         Cells[Col, Row + 1] := '1';
  496.         Cells[Col, Z_DATA_LINE] := '';
  497.       end
  498.       else if (Cells[Col, Row] = 'Y') then
  499.       begin
  500.         Cells[Col, Row] := 'Z';
  501.         Cells[Col, Row + 1] := '';
  502.         Cells[Col, Z_DATA_LINE] := '';
  503.       end
  504.       else if (Cells[Col, Row] = 'Z') then
  505.       begin
  506.         Cells[Col, Row] := 'ignore';
  507.         Cells[Col, Row + 1] := '';
  508.         Cells[Col, Z_DATA_LINE] := '';
  509.       end
  510.       else
  511.       begin
  512.         Cells[Col, Row] := 'X';
  513.         Cells[Col, Row + 1] := '';
  514.         Cells[Col, Z_DATA_LINE] := '';
  515.       end;
  516.       CalculateNoSeries;
  517.     end;
  518.  
  519.     if ((Row = DEPENDS_ON_X) and (Col > 2)) then
  520.     begin
  521.       TheCol := Col;
  522.       TheRow := Row;
  523.       {Rect := TRect(CellRect(Col, Row));}
  524.       Rect := CellRect(TheCol, TheRow);
  525.       PickXDataComboBox.Left :=
  526.         InfoGrid.Left + Rect.Left;
  527.       PickXDataComboBox.Top :=
  528.         InfoGrid.Top + Rect.Top;
  529.       PickXDataComboBox.Width := Rect.Right - Rect.Left;
  530.       PickXDataComboBox.Height := Rect.Bottom - Rect.Top;
  531.       PickXDataComboBox.Clear;
  532.       for iColumn := 1 to ColCount-1 do
  533.       begin
  534.         if (Cells[iColumn, X_OR_Y_OR_Z] = 'X') then
  535.           PickXDataComboBox.Items.Add(IntToStr(iColumn));
  536.       end;
  537.       PickXDataComboBox.Visible := TRUE;
  538.     end;
  539.  
  540. {Is there X Data ?}
  541.     LocalXDataPresent := FALSE;
  542.     for iColumn := 1 to ColCount-1 do
  543.     begin
  544.       if (Cells[iColumn, X_OR_Y_OR_Z] = 'X') then
  545.       begin
  546.         LocalXDataPresent := TRUE;
  547.         iXColumn := iColumn;
  548.         break;
  549.       end;
  550.     end;
  551.     if (LocalXDataPresent) then
  552.     begin
  553.       if (not XDataPresent) then
  554. {Oh merde ! we have to put ALL the X's back in !}
  555.       begin
  556.         TheText := IntToStr(iXColumn);
  557.         for iColumn := 1 to ColCount-1 do
  558.           if (Cells[iColumn, X_OR_Y_OR_Z] = 'Y') then
  559.             Cells[iColumn, DEPENDS_ON_X] := TheText;
  560.       end;
  561.     end
  562.     else
  563.     begin
  564.       for iColumn := 1 to ColCount-1 do
  565.         Cells[iColumn, DEPENDS_ON_X] := '';
  566.     end;
  567.     XDataPresent := LocalXDataPresent;
  568.   end; {with InfoGrid}
  569. end;
  570.  
  571. {------------------------------------------------------------------------------
  572.     Procedure: TParserForm.PickXDataComboBoxClick
  573.   Description: responds to the selection of a particular X Data column
  574.        Author: Mat Ballard
  575.  Date created: 04/25/2000
  576. Date modified: 04/25/2000 by Mat Ballard
  577.       Purpose: sets the XData column
  578.  Known Issues:
  579.  ------------------------------------------------------------------------------}
  580. procedure TParserForm.PickXDataComboBoxClick(Sender: TObject);
  581. begin
  582.   with PickXDataComboBox do
  583.   begin
  584.     Visible := FALSE;
  585.     if (ItemIndex >= 0) then
  586.       InfoGrid.Cells[TheCol, TheRow] := Items[ItemIndex];
  587.   end;
  588. end;
  589.  
  590. procedure TParserForm.HelpBitBtnClick(Sender: TObject);
  591. {$IFDEF LINUX}
  592. var
  593.   TheHelpFile: String;
  594. {$ENDIF}
  595. begin
  596. {$IFDEF LINUX}
  597.   TheHelpFile := 'hs' + IntToStr(HelpBitBtn.HelpContext) + '.htm';
  598. {$ENDIF}
  599. end;
  600.  
  601. procedure TParserForm.ZDataLineButtonClick(Sender: TObject);
  602. var
  603.   TheLine: String;
  604.   iColumn: Integer;
  605. begin
  606.   TheZDataLine := DataListBox.ItemIndex;
  607.   TheLine := DataListBox.Items[DataListBox.ItemIndex];
  608.   iColumn := 1;
  609.   while (Length(TheLine) > 0) do
  610.   begin
  611.     if (InfoGrid.ColCount <= iColumn) then
  612.       InfoGrid.ColCount := iColumn+1;
  613.     InfoGrid.Cells[iColumn, Z_DATA_LINE] :=
  614.       GetWord(TheLine, Delimiters[TheDelimiter]);
  615.     Inc(iColumn);
  616.   end;
  617. end;
  618.  
  619.  
  620. procedure TParserForm.FormResize(Sender: TObject);
  621. begin
  622.   Self.ClientHeight := OriginalHeight;
  623.   DataListBox.Width := Self.ClientWidth - 2*DataListBox.Left;
  624.   LineEdit.Width := Self.ClientWidth - 2*DataListBox.Left;
  625.   InfoGrid.Width := Self.ClientWidth - 2*DataListBox.Left;
  626. end;
  627.  
  628. procedure TParserForm.ExpandBitBtnClick(Sender: TObject);
  629. begin
  630.   if (ExpandBitBtn.Tag = 0) then
  631.   begin
  632.     Self.Width := Screen.Width - Self.Left;
  633.     ExpandBitBtn.Caption := sContract;
  634.     ExpandBitBtn.Tag := 1;
  635.   end
  636.   else
  637.   begin
  638.     Self.Width := SetGroupBox.Left + SetGroupBox.Width + HelpBitBtn.Left;
  639.     ExpandBitBtn.Caption := sExpand;
  640.     ExpandBitBtn.Tag := 0;
  641.   end;
  642. end;
  643.  
  644. procedure TParserForm.Timer1Timer(Sender: TObject);
  645. begin
  646.   InstructionIndex := (InstructionIndex+1) mod 7;
  647.   InstructionsLabel.Caption := Instructions[InstructionIndex];
  648. end;
  649.  
  650. end.
  651.