1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
|
unit LR_EditVariables;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
Buttons, ButtonPanel, LR_Intrp;
type
{ TlrEditVariablesForm }
TlrEditVariablesForm = class(TForm)
BitBtn1: TBitBtn;
ButtonPanel1: TButtonPanel;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
ListBox1: TListBox;
Memo2: TMemo;
procedure BitBtn1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure ListBox1Click(Sender: TObject);
private
EditItem:integer;
ValList:TStringList;
public
procedure LoadParamList(AVars:TfrVariables);
procedure SaveParamList(AVars:TfrVariables);
end;
var
lrEditVariablesForm: TlrEditVariablesForm;
implementation
uses lr_expres;
{$R *.lfm}
{ TlrEditVariablesForm }
procedure TlrEditVariablesForm.ListBox1Click(Sender: TObject);
begin
if (ListBox1.Items.Count>0) and (ListBox1.ItemIndex > -1) and (ListBox1.ItemIndex<ListBox1.Items.Count) then
begin
if EditItem>-1 then
ValList.Values[ListBox1.Items[EditItem]]:=Memo2.Text;
EditItem:=ListBox1.ItemIndex;
Memo2.Text:=ValList.Values[ListBox1.Items[EditItem]];
end;
end;
procedure TlrEditVariablesForm.FormCreate(Sender: TObject);
begin
ValList:=TStringList.Create;
Memo2.Text:='';
end;
procedure TlrEditVariablesForm.BitBtn1Click(Sender: TObject);
var
EF:TlrExpresionEditorForm;
begin
EF:=TlrExpresionEditorForm.Create(Application);
if EF.ShowModal = mrOk then
Memo2.Text:=EF.ResultExpresion;
EF.Free;
end;
procedure TlrEditVariablesForm.FormDestroy(Sender: TObject);
begin
FreeAndNil(ValList);
end;
procedure TlrEditVariablesForm.LoadParamList(AVars: TfrVariables);
var
i:integer;
begin
ListBox1.Items.Clear;
for i:=0 to AVars.Count - 1 do
begin
ListBox1.Items.Add(AVars.Name[i]);
ValList.Values[AVars.Name[i]]:=AVars.Value[i];
end;
EditItem:=-1;
Memo2.Enabled:=ListBox1.Items.Count>0;
ListBox1.Enabled:=ListBox1.Items.Count>0;
if ListBox1.Items.Count>0 then
begin
ListBox1.ItemIndex:=0;
ListBox1Click(nil);
end;
end;
procedure TlrEditVariablesForm.SaveParamList(AVars: TfrVariables);
var
i:integer;
begin
ListBox1Click(nil);
AVars.Clear;
for i:=0 to ListBox1.Items.Count - 1 do
AVars[ListBox1.Items[i]]:=ValList.Values[ListBox1.Items[i]];
end;
end.
|