Thank you a lot,
Blaazen! It works!
if length(field.text)=0 then exit; //ADD THIS LINE
Done.
You shouldn't have Application.Terminate on closing of main form. When you close main form then app is terminated automaticly.
Thanks for the advice. Actually, I set calculator form to be main temporarily
.
EDIT2:
Bug: You delete something and then you assign it ! :-)
procedure Tcalculator_mode.plusClick(Sender: TObject);
begin
gncalc.plus:=true;
field.text:='';
gncalc.Operand_0:=field.text;
end;
must be :
procedure Tcalculator_mode.plusClick(Sender: TObject);
begin
gncalc.plus:=true;
gncalc.Operand_0:=field.text;
field.text:='';
end;
Fixed. I also added to every button click procedure a boolean which shows whether the first operand is entered, and if it's not - the procedures are exited without doing anything.
And TMemo loses focus after pressing "C".
Fixed too. BTW it's an interesting thing: TMemo loses focus on pressing "=" or "C" and stays focused on pressing "+" or "-" - why does it happen?
EDIT:
So, finally I've got it 100% working
.
Blaazen, thank you once more - you saved a lot of my time, I think.