Recent

Author Topic: Compiler error on Application.CreateForm  (Read 13242 times)

dkjMusic

  • Full Member
  • ***
  • Posts: 146
Compiler error on Application.CreateForm
« on: November 22, 2010, 09:45:53 pm »
When I add AboutForm to the list of Auto-created forms in the project options, I get a compiler error as shown below:

begin
  Application.Title:='801Review';
  {$I project1.lrs}
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Application.CreateForm(TAboutForm, AboutForm); <--- error here (see below)
  Application.Run;
end.

error is:
project1.lpr(19,47) Fatal: Syntax error, "." expected but ")" found

What is wrong?
Windows 7 Ultimate/32 bit;
Lazarus 0.9.31/Rev 33300;
FPC 2.7.1/Rev 19464;
GDB 7.0.50;
(via CodeTyphon 2.30)

ivan17

  • Full Member
  • ***
  • Posts: 173
Re: Compiler error on Application.CreateForm
« Reply #1 on: November 23, 2010, 06:37:27 am »
{$I project1.lrs}  is seriously out of place

dkjMusic

  • Full Member
  • ***
  • Posts: 146
Re: Compiler error on Application.CreateForm
« Reply #2 on: November 23, 2010, 10:58:04 am »
{$I project1.lrs}  is seriously out of place

Then why does this run with no problem:

begin
  Application.Title:='project1';
  {$I project1.lrs}
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Application.CreateForm(TForm2, Form2);
  Application.Run;
end.
Windows 7 Ultimate/32 bit;
Lazarus 0.9.31/Rev 33300;
FPC 2.7.1/Rev 19464;
GDB 7.0.50;
(via CodeTyphon 2.30)

DirkS

  • Sr. Member
  • ****
  • Posts: 251
Re: Compiler error on Application.CreateForm
« Reply #3 on: November 23, 2010, 11:13:58 am »
Quote
Then why does this run with no problem:
Most likely pure luck  :o

Did you try moving the line and compile again?

Gr.
Dirk.

dkjMusic

  • Full Member
  • ***
  • Posts: 146
Re: Compiler error on Application.CreateForm
« Reply #4 on: November 23, 2010, 11:15:25 am »
Quote
Then why does this run with no problem:
Most likely pure luck  :o

Did you try moving the line and compile again?

Gr.
Dirk.


Move it where?
Windows 7 Ultimate/32 bit;
Lazarus 0.9.31/Rev 33300;
FPC 2.7.1/Rev 19464;
GDB 7.0.50;
(via CodeTyphon 2.30)

Vincent Snijders

  • Administrator
  • Hero Member
  • *
  • Posts: 2661
    • My Lazarus wiki user page
Re: Compiler error on Application.CreateForm
« Reply #5 on: November 23, 2010, 01:03:57 pm »
In what unit is the AboutForm form declared. I hope it is not "aboutform".

dkjMusic

  • Full Member
  • ***
  • Posts: 146
Re: Compiler error on Application.CreateForm
« Reply #6 on: November 23, 2010, 05:31:21 pm »
In what unit is the AboutForm form declared. I hope it is not "aboutform".

Yep, sure is. Each object needs a unique name, right? I just tracked this down earlier this morning when I started the project all over and Lazarus complained about trying to save the unit with the same name as the form. Before, I think I had saved the unit as AboutForm.pas before renaming the form to AboutForm, without an error. Live and learn.

Thanks for confirming.
Windows 7 Ultimate/32 bit;
Lazarus 0.9.31/Rev 33300;
FPC 2.7.1/Rev 19464;
GDB 7.0.50;
(via CodeTyphon 2.30)

Vincent Snijders

  • Administrator
  • Hero Member
  • *
  • Posts: 2661
    • My Lazarus wiki user page
Re: Compiler error on Application.CreateForm
« Reply #7 on: November 23, 2010, 05:35:17 pm »
Code: [Select]
Application.CreateForm(TAboutForm, AboutForm.AboutForm); would have worked too, I think. The IDE is not that smart though.

Or maybe resilient is a better word.

 

TinyPortal © 2005-2018