Bart was faster. But I think my explanation may still provide some useful info.I cannot fully understand what you meant or what you wanted do, but I think you didn't know what the 'modal' means.
The error can be solved by simply removing/commenting
line #35. The error happens because you're not allow to call a form to show modal before you close the (non-modal) form. It is a bit hard to explain using words, something like this:
- Call Form.Show and then Form.Show ---> no problem
- Call Form.ShowModal and then Form.ShowModal ---> no problem
- Call Form.ShowModal and then Form.Show ---> no problem
- Call Form.Show and then Form.ShowModal --->
it is not allowedYou may ask why, it is understandable if you really understand what the 'modal' means.
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
Unit2;
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
public
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.Button1Click(Sender: TObject);
begin
// Form2.Show;
if form2.ShowModal = mrOK then
begin
ShowMessage('User pressed OK, need to check data.');
end;
end;
end.