@@ -196,6 +196,7 @@ TFormMain = class(TForm)
196
196
TransientType: TTransientType);
197
197
procedure synEditCPaintTransient (Sender: TObject; Canvas: TCanvas;
198
198
TransientType: TTransientType);
199
+ procedure mmoCalcResClick (Sender: TObject);
199
200
private
200
201
{ Private declarations }
201
202
@@ -528,6 +529,15 @@ procedure TFormMain.btnLittleC_clearClick(Sender: TObject);
528
529
mmoOutC.Clear;
529
530
end ;
530
531
532
+ procedure TFormMain.mmoCalcResClick (Sender: TObject);
533
+ var
534
+ s: string;
535
+ begin
536
+ s := mmoCalcRes.Lines[mmoCalcRes.CaretPos.Y];
537
+ if s <> ' ' then
538
+ cbbCalcExpress.Text := s;
539
+ end ;
540
+
531
541
procedure TFormMain.mmoOutBasAdd (s: string);
532
542
begin
533
543
mmoOutBas.Lines.BeginUpdate;
@@ -934,12 +944,22 @@ procedure TFormMain.cbbCalcExpressDblClick(Sender: TObject);
934
944
try
935
945
if mmoCalcVar.Modified then
936
946
begin
937
- mmoCalcVar.Modified := False;
938
947
Calc.Clear;
939
948
Calc.AddVariableList(mmoCalcVar.Lines);
949
+ mmoCalcVar.Clear;
950
+ for n := 0 to Calc.Count - 1 do
951
+ begin
952
+ mmoCalcVar.Lines.Add(Calc.ItemName[n] + ' = ' + Calc.ItemValueFromIndex[n]);
953
+ if Calc.ItemName[n] = ' x' then
954
+ begin
955
+ MessageDlg(' If x is used as the variable name, '' 0x'' cannot be used in the expression.' ,
956
+ mtWarning, [mbOK], 0 );
957
+ end ;
958
+ end ;
959
+ mmoCalcVar.Modified := False;
940
960
end ;
941
961
res := Calc.AsString(cbbCalcExpress.Text);
942
- mmoCalcRes.Lines.Add(cbbCalcExpress.Text + ' =' );
962
+ mmoCalcRes.Lines.Add(Trim( cbbCalcExpress.Text) + ' =' );
943
963
mmoCalcRes.Lines.Add(res);
944
964
n := cbbCalcExpress.Items.IndexOf(cbbCalcExpress.Text);
945
965
if n = -1 then
@@ -950,17 +970,17 @@ procedure TFormMain.cbbCalcExpressDblClick(Sender: TObject);
950
970
end
951
971
else
952
972
cbbCalcExpress.Items.Move(n, 0 );
953
- cbbCalcExpress.SelectAll;
973
+
954
974
except
955
- mmoCalcRes.Lines.Add(' Expression <' + cbbCalcExpress.Text + ' > Error!' );
975
+ mmoCalcRes.Lines.Add(' Expression < ' + Trim(cbbCalcExpress.Text) + ' > Error!' );
976
+ cbbCalcExpress.SelectAll;
956
977
end ;
957
978
finally
958
979
mmoCalcRes.Lines.Add(' ' );
959
- if mmoCalcRes.Lines.Count > 4096 then
980
+ if mmoCalcRes.Lines.Count > 4095 then
960
981
begin
961
- mmoCalcRes.Lines.Delete(0 );
962
- mmoCalcRes.Lines.Delete(0 );
963
- mmoCalcRes.Lines.Delete(0 );
982
+ for n := 1 to 128 * 3 do
983
+ mmoCalcRes.Lines.Delete(0 );
964
984
end ;
965
985
end ;
966
986
end ;
@@ -1078,7 +1098,7 @@ procedure TFormMain.FormCreate(Sender: TObject);
1078
1098
pnlCalcVar.Width := ini.ReadInteger(' CalcExpr' , ' Width' , mmoCalcRes.Width);
1079
1099
ini.ReadStrings(' CalcExpr' , ' vars' , mmoCalcVar.Lines);
1080
1100
if mmoCalcVar.Text = ' ' then
1081
- mmoCalcVar.Text := ' x=10 ' # 13 # 10 ' y=0x12' #13 #10 ' f=x+y ' ;
1101
+ mmoCalcVar.Text := ' y=0x12' #13 #10 ' f=y*y+2 ' ;
1082
1102
mmoCalcVar.Modified := True;
1083
1103
except
1084
1104
ini_writeable := False;
@@ -1155,6 +1175,7 @@ procedure TFormMain.FormKeyDown(Sender: TObject; var Key: Word;
1155
1175
0 : btnLittleC_runClick(Sender);
1156
1176
1 : btnPas_runClick(Sender);
1157
1177
2 : btnBas_runClick(Sender);
1178
+ 3 : cbbCalcExpressDblClick(Sender);
1158
1179
end ;
1159
1180
end ;
1160
1181
VK_F10:
0 commit comments