home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 September / Chip_2001-09_cd1.bin / zkuste / delphi / kolekce / d12345 / CHEMPLOT.ZIP / TPlot / Parser.pas < prev    next >
Pascal/Delphi Source File  |  2001-05-16  |  20KB  |  599 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;
  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.     ('None', 'Tab  ->', 'Comma  ,', 'Space   ', 'Colon  ;', 'Semicolon  :', 'Line Feed  ┐', 'Type your own');
  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.     Label1: TLabel;
  105.     DelimiterComboBox: TComboBox;
  106.     LineEdit: TEdit;
  107.     GroupBox1: 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.   end;
  150.  
  151. var
  152.   ParserForm: TParserForm;
  153.  
  154. implementation
  155.  
  156. {$R *.dfm}
  157.  
  158. resourcestring
  159.   sInstruction1 = '1. Select the first line of data, and click on the "1st line of data" button. This enables the "ZData Line " button';
  160.   sInstruction2 = '2. Select the line containing the names of the Series, by clicking on the "Series Names" button, or just type into the Grid.';
  161.   sInstruction3 = '3. Expand the Grid, if needed by clicking on the "Expand" button.';
  162.   sInstruction4 = '4. Set the column type: X, XTEXT, Y, Z or ignore, by clicking on the "Y" in the "X or Y Data ?" line, if needed';
  163.   sInstruction5 = '5. Set the column in which the X Data is located, if needed';
  164.   sInstruction6 = '6. If there is a line (row) of Z Data, select it by clicking on the "Z Data Line" button';
  165.   sInstruction7 = '7. If you want to add the Z Data manually, type it into the last row of the grid under the Y values';
  166.  
  167. const
  168.   Instructions: array[0..6] of string =
  169.    (sInstruction1,
  170.     sInstruction2,
  171.     sInstruction3,
  172.     sInstruction4,
  173.     sInstruction5,
  174.     sInstruction6,
  175.     sInstruction7);
  176.  
  177.   {Delimiters[dlNone] := '';
  178.   DelimiterNames[dlNone] := 'None';
  179. Tabs come from spreadsheet / table data from the clipboard:
  180.   Delimiters[dlTab] := #9;
  181.   DelimiterNames[dlTab] := 'Tab   ->';
  182. Commas come from disk data:
  183.   Delimiters[dlComma] := ',';
  184.   DelimiterNames[dlComma] := 'Comma  ,';
  185.   Delimiters[dlSpace] := ' ';
  186.   DelimiterNames[dlSpace] := 'Space   ';
  187.   Delimiters[dlColon] := ';';
  188.   DelimiterNames[dlColon] := 'Colon  ;';
  189.   Delimiters[dlSemicolon] := #58;
  190.   DelimiterNames[dlSemicolon] := 'Semicolon  :';
  191.   Delimiters[dlLinefeed] := #10;
  192.   DelimiterNames[dlLinefeed] := 'Line Feed   ┐';
  193.   Delimiters[dlOwn] := 'Type your own';
  194.   DelimiterNames[dlOwn] := 'Type your own';}
  195.  
  196.  
  197. {------------------------------------------------------------------------------
  198.     Procedure: TParserForm.FormCreate
  199.   Description: standard FormCreate procedure
  200.        Author: Mat Ballard
  201.  Date created: 04/25/2000
  202. Date modified: 04/09/2001 by Mat Ballard
  203.       Purpose: sets the position, the Delimiters and their names, and putsw headings on the stringgrid
  204.  Known Issues:
  205.  ------------------------------------------------------------------------------}
  206. procedure TParserForm.FormCreate(Sender: TObject);
  207. var
  208.   iDelimiter: TDelimiter;
  209. begin
  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.   ZDataLineButton.Hint :=
  227.     'The line containing the Z Data;' + #10 +
  228.     'If not set, or typed in, you will be prompted for values for 3D plots.';
  229.   TheZDataLine := -1;
  230.   TheFirstDataLine := -1;
  231.   TheSeriesNamesLine := -1;
  232.   TheSeriesUnitsLine := -1;
  233.   XDataPresent := TRUE;
  234.  
  235.   InstructionIndex := 0;
  236.   InstructionsLabel.Caption := Instructions[InstructionIndex];
  237.  
  238.   Delimiters[dlNone] := '';
  239. {Tabs come from spreadsheet / table data from the clipboard:}
  240.   Delimiters[dlTab] := #9;
  241. {Commas come from disk data:}
  242.   Delimiters[dlComma] := ',';
  243.   Delimiters[dlSpace] := ' ';
  244.   Delimiters[dlColon] := ';';
  245.   Delimiters[dlSemicolon] := ':';
  246.   Delimiters[dlLinefeed] := #10;
  247.   Delimiters[dlOwn] := 'Type your own';
  248.   for iDelimiter := dlNone to dlOwn do
  249.   begin
  250.     DelimiterComboBox.Items.Add(DelimiterNames[iDelimiter]);
  251.   end;
  252.  
  253.   with InfoGrid do
  254.   begin
  255.     Cells[0, COLUMN_NOS] := 'Column Number:';
  256.     Cells[0, SERIES_NAMES] := 'Series Names:';
  257.     Cells[0, FIRST_LINE_OF_DATA] := '1st Line of Data:';
  258.     Cells[0, X_OR_Y_OR_Z] := 'X, Y or Z data ?';
  259.     Cells[0, DEPENDS_ON_X] := 'X Data in Column #:';
  260.     Cells[0, Z_DATA_LINE] := 'Z Data:';
  261.     DefaultColWidth := 80;
  262.     ColWidths[0] := 130;
  263.   end;
  264. end;
  265.  
  266. {------------------------------------------------------------------------------
  267.     Procedure: TParserForm.DataListBoxClick
  268.   Description: responds to user selection of a line
  269.        Author: Mat Ballard
  270.  Date created: 04/25/2000
  271. Date modified: 04/25/2000 by Mat Ballard
  272.       Purpose: places the selected line into the Edit box, and checks it for Delimiters
  273.  Known Issues:
  274.  ------------------------------------------------------------------------------}
  275. procedure TParserForm.DataListBoxClick(Sender: TObject);
  276. begin
  277.   LineEdit.Text := DataListBox.Items[DataListBox.ItemIndex];
  278.   CheckDelimiter;
  279. end;
  280.  
  281. {------------------------------------------------------------------------------
  282.     Procedure: TParserForm.CheckDelimiter
  283.   Description: determines the Delimiter in a line
  284.        Author: Mat Ballard
  285.  Date created: 04/25/2000
  286. Date modified: 04/25/2000 by Mat Ballard
  287.       Purpose: sets Delimiter
  288.  Known Issues:
  289.  ------------------------------------------------------------------------------}
  290. procedure TParserForm.CheckDelimiter;
  291. var
  292.   iDelimiter: TDelimiter;
  293. begin
  294.   TheDelimiter := dlNone;
  295.   for iDelimiter := dlTab to dlLineFeed do
  296.   begin
  297.     if (Pos(Delimiters[iDelimiter], LineEdit.Text) > 0) then
  298.     begin
  299.       TheDelimiter := iDelimiter;
  300.       break;
  301.     end;
  302.   end;
  303.   DelimiterComboBox.ItemIndex := Ord(TheDelimiter);
  304. end;
  305.  
  306. {------------------------------------------------------------------------------
  307.     Procedure: TParserForm.CalculateNoSeries
  308.   Description: Calculates the number of Series (Y columns)
  309.        Author: Mat Ballard
  310.  Date created: 04/09/2001
  311. Date modified: 04/09/2001 by Mat Ballard
  312.       Purpose: see Description
  313.  Known Issues:
  314.  ------------------------------------------------------------------------------}
  315. procedure TParserForm.CalculateNoSeries;
  316. var
  317.   iColumn: Integer;
  318. begin
  319.   NumberOfSeries := 0;
  320.   for iColumn := 2 to InfoGrid.ColCount-1 do
  321.   begin
  322.     if (InfoGrid.Cells[iColumn, X_OR_Y_OR_Z] = 'Y') then
  323.       Inc(NumberOfSeries);
  324.   end;
  325.   NoSeriesLabel.Caption := Format('There seems to be %d Series', [NumberOfSeries]);
  326. end;
  327.  
  328. {------------------------------------------------------------------------------
  329.     Procedure: TParserForm.FirstLineOfDataButtonClick
  330.   Description: responds to the selection of the first line of data
  331.        Author: Mat Ballard
  332.  Date created: 04/25/2000
  333. Date modified: 04/25/2000 by Mat Ballard
  334.       Purpose: fills the InfoGrid cells with the parsed line
  335.  Known Issues:
  336.  ------------------------------------------------------------------------------}
  337. procedure TParserForm.FirstLineOfDataButtonClick(Sender: TObject);
  338. var
  339.   TheLine: String;
  340.   iColumn: Integer;
  341. begin
  342.   ZDataLineButton.Enabled := TRUE;
  343.   
  344.   TheFirstDataLine := DataListBox.ItemIndex;
  345.   TheLine := DataListBox.Items[DataListBox.ItemIndex];
  346.   iColumn := 1;
  347.   {InfoGrid.ColCount := 3;}
  348.   while (Length(TheLine) > 0) do
  349.   begin
  350.     if (InfoGrid.ColCount <= iColumn) then
  351.       InfoGrid.ColCount := iColumn+1;
  352.     InfoGrid.Cells[iColumn, FIRST_LINE_OF_DATA] :=
  353.       GetWord(TheLine, Delimiters[TheDelimiter]);
  354.     Inc(iColumn);
  355.   end;
  356.  
  357.   for iColumn := 1 to InfoGrid.ColCount-1 do
  358.   begin
  359.     InfoGrid.Cells[iColumn, COLUMN_NOS] := IntToStr(iColumn);
  360.   end;
  361.  
  362.   InfoGrid.Cells[1, X_OR_Y_OR_Z] := 'X';
  363.   for iColumn := 2 to InfoGrid.ColCount-1 do
  364.   begin
  365.     InfoGrid.Cells[iColumn, X_OR_Y_OR_Z] := 'Y';
  366.   end;
  367.  
  368.   InfoGrid.Cells[1, DEPENDS_ON_X] := '';
  369.   for iColumn := 2 to InfoGrid.ColCount-1 do
  370.   begin
  371.     InfoGrid.Cells[iColumn, DEPENDS_ON_X] := '1';
  372.   end;
  373.  
  374.   OKBitBtn.Enabled := TRUE;
  375.  
  376.   CalculateNoSeries;  
  377. end;
  378.  
  379. {------------------------------------------------------------------------------
  380.     Procedure: TParserForm.SeriesNamesButtonClick
  381.   Description: responds to the selection of the Series names
  382.        Author: Mat Ballard
  383.  Date created: 04/25/2000
  384. Date modified: 04/25/2000 by Mat Ballard
  385.       Purpose: fills the InfoGrid Series Names row with the parsed line
  386.  Known Issues:
  387.  ------------------------------------------------------------------------------}
  388. procedure TParserForm.SeriesNamesButtonClick(Sender: TObject);
  389. var
  390.   TheLine: String;
  391.   iColumn: Integer;
  392. begin
  393.   TheSeriesNamesLine := DataListBox.ItemIndex;
  394.   TheLine := DataListBox.Items[DataListBox.ItemIndex];
  395.   iColumn := 1;
  396.   while (Length(TheLine) > 0) do
  397.   begin
  398.     if (InfoGrid.ColCount <= iColumn) then
  399.       InfoGrid.ColCount := iColumn+1;
  400.     InfoGrid.Cells[iColumn, SERIES_NAMES] :=
  401.       GetWord(TheLine, Delimiters[TheDelimiter]);
  402.     Inc(iColumn);
  403.   end;
  404.   InfoGrid.ColCount := iColumn;
  405.  
  406.   for iColumn := 1 to InfoGrid.ColCount-1 do
  407.   begin
  408.     InfoGrid.Cells[iColumn, COLUMN_NOS] := IntToStr(iColumn);
  409.   end;
  410. end;
  411.  
  412. {------------------------------------------------------------------------------
  413.     Procedure: TParserForm.InfoGridClick
  414.   Description: responds to the selection of a cell in the StringGrid
  415.        Author: Mat Ballard
  416.  Date created: 04/25/2000
  417. Date modified: 04/25/2000 by Mat Ballard
  418.       Purpose: sets the InfoGrid options, contents of some cells, and PickXDataComboBox position and visibility
  419.  Known Issues:
  420.  ------------------------------------------------------------------------------}
  421. procedure TParserForm.InfoGridClick(Sender: TObject);
  422. var
  423.   Rect: TRect;
  424.   iColumn, iXColumn: Integer;
  425.   LocalXDataPresent: Boolean;
  426.   TheText: String;
  427. begin
  428.   with InfoGrid do
  429.   begin
  430.     if (((Row = SERIES_NAMES) or
  431.          (Row = Z_DATA_LINE)) and
  432.          (Col > 0)) then
  433.     begin
  434.       Options := [goFixedVertLine,goFixedHorzLine,goVertLine,goHorzLine,
  435.         goDrawFocusSelected,goColSizing, goEditing];
  436.     end
  437.     else
  438.     begin
  439.       Options := [goFixedVertLine,goFixedHorzLine,goVertLine,goHorzLine,
  440.         goDrawFocusSelected,goColSizing];
  441.     end;
  442.  
  443.     if ((Row = X_OR_Y_OR_Z) and (Col >= 1)) then
  444.     begin
  445.       if (Cells[Col, Row] = 'X') then
  446.       begin
  447.         Cells[Col, Row] := 'XTEXT';
  448.         Cells[Col, Row + 1] := '';
  449.         Cells[Col, Z_DATA_LINE] := '';
  450.       end
  451.       else if (Cells[Col, Row] = 'XTEXT') then
  452.       begin
  453.         Cells[Col, Row] := 'Y';
  454.         Cells[Col, Row + 1] := '1';
  455.         Cells[Col, Z_DATA_LINE] := '';
  456.       end
  457.       else if (Cells[Col, Row] = 'Y') then
  458.       begin
  459.         Cells[Col, Row] := 'Z';
  460.         Cells[Col, Row + 1] := '';
  461.         Cells[Col, Z_DATA_LINE] := '';
  462.       end
  463.       else if (Cells[Col, Row] = 'Z') then
  464.       begin
  465.         Cells[Col, Row] := 'ignore';
  466.         Cells[Col, Row + 1] := '';
  467.         Cells[Col, Z_DATA_LINE] := '';
  468.       end
  469.       else
  470.       begin
  471.         Cells[Col, Row] := 'X';
  472.         Cells[Col, Row + 1] := '';
  473.         Cells[Col, Z_DATA_LINE] := '';
  474.       end;
  475.       CalculateNoSeries;
  476.     end;
  477.  
  478.     if ((Row = DEPENDS_ON_X) and (Col > 2)) then
  479.     begin
  480.       TheCol := Col;
  481.       TheRow := Row;
  482.       {Rect := TRect(CellRect(Col, Row));}
  483.       Rect := CellRect(TheCol, TheRow);
  484.       PickXDataComboBox.Left :=
  485.         InfoGrid.Left + Rect.Left;
  486.       PickXDataComboBox.Top :=
  487.         InfoGrid.Top + Rect.Top;
  488.       PickXDataComboBox.Width := Rect.Right - Rect.Left;
  489.       PickXDataComboBox.Height := Rect.Bottom - Rect.Top;
  490.       PickXDataComboBox.Clear;
  491.       for iColumn := 1 to ColCount-1 do
  492.       begin
  493.         if (Cells[iColumn, X_OR_Y_OR_Z] = 'X') then
  494.           PickXDataComboBox.Items.Add(IntToStr(iColumn));
  495.       end;
  496.       PickXDataComboBox.Visible := TRUE;
  497.     end;
  498.  
  499. {Is there X Data ?}
  500.     LocalXDataPresent := FALSE;
  501.     for iColumn := 1 to ColCount-1 do
  502.     begin
  503.       if (Cells[iColumn, X_OR_Y_OR_Z] = 'X') then
  504.       begin
  505.         LocalXDataPresent := TRUE;
  506.         iXColumn := iColumn;
  507.         break;
  508.       end;
  509.     end;
  510.     if (LocalXDataPresent) then
  511.     begin
  512.       if (not XDataPresent) then
  513. {Oh merde ! we have to put ALL the X's back in !}
  514.       begin
  515.         TheText := IntToStr(iXColumn);
  516.         for iColumn := 1 to ColCount-1 do
  517.           if (Cells[iColumn, X_OR_Y_OR_Z] = 'Y') then
  518.             Cells[iColumn, DEPENDS_ON_X] := TheText;
  519.       end;
  520.     end
  521.     else
  522.     begin
  523.       for iColumn := 1 to ColCount-1 do
  524.         Cells[iColumn, DEPENDS_ON_X] := '';
  525.     end;
  526.     XDataPresent := LocalXDataPresent;
  527.   end; {with InfoGrid}
  528. end;
  529.  
  530. {------------------------------------------------------------------------------
  531.     Procedure: TParserForm.PickXDataComboBoxClick
  532.   Description: responds to the selection of a particular X Data column
  533.        Author: Mat Ballard
  534.  Date created: 04/25/2000
  535. Date modified: 04/25/2000 by Mat Ballard
  536.       Purpose: sets the XData column
  537.  Known Issues:
  538.  ------------------------------------------------------------------------------}
  539. procedure TParserForm.PickXDataComboBoxClick(Sender: TObject);
  540. begin
  541.   with PickXDataComboBox do
  542.   begin
  543.     Visible := FALSE;
  544.     if (ItemIndex >= 0) then
  545.       InfoGrid.Cells[TheCol, TheRow] := Items[ItemIndex];
  546.   end;
  547. end;
  548.  
  549. procedure TParserForm.HelpBitBtnClick(Sender: TObject);
  550. {$IFDEF LINUX}
  551. var
  552.   TheHelpFile: String;
  553. {$ENDIF}
  554. begin
  555. {$IFDEF LINUX}
  556.   TheHelpFile := 'hs' + IntToStr(HelpBitBtn.HelpContext) + '.htm';
  557. {$ENDIF}
  558. end;
  559.  
  560. procedure TParserForm.ZDataLineButtonClick(Sender: TObject);
  561. var
  562.   TheLine: String;
  563.   iColumn: Integer;
  564. begin
  565.   TheZDataLine := DataListBox.ItemIndex;
  566.   TheLine := DataListBox.Items[DataListBox.ItemIndex];
  567.   iColumn := 1;
  568.   while (Length(TheLine) > 0) do
  569.   begin
  570.     if (InfoGrid.ColCount <= iColumn) then
  571.       InfoGrid.ColCount := iColumn+1;
  572.     InfoGrid.Cells[iColumn, Z_DATA_LINE] :=
  573.       GetWord(TheLine, Delimiters[TheDelimiter]);
  574.     Inc(iColumn);
  575.   end;
  576. end;
  577.  
  578.  
  579. procedure TParserForm.FormResize(Sender: TObject);
  580. begin
  581.   Self.ClientHeight := OriginalHeight;
  582.   DataListBox.Width := Self.ClientWidth - 2*DataListBox.Left;
  583.   LineEdit.Width := Self.ClientWidth - 2*DataListBox.Left;
  584.   InfoGrid.Width := Self.ClientWidth - 2*DataListBox.Left;
  585. end;
  586.  
  587. procedure TParserForm.ExpandBitBtnClick(Sender: TObject);
  588. begin
  589.   Self.Width := Screen.Width - 10;
  590. end;
  591.  
  592. procedure TParserForm.Timer1Timer(Sender: TObject);
  593. begin
  594.   InstructionIndex := (InstructionIndex+1) mod 7;
  595.   InstructionsLabel.Caption := Instructions[InstructionIndex];
  596. end;
  597.  
  598. end.
  599.