Delphi XE2 16 Compiling problem

Hello,

I have a rather peculiar problem while compiling projects in Delphi. I am a novice user and started recently.

The problem:
If I code a project it will compile the first time without error. However, if I ad more to the code it won't compile and give the error: "[DCC Error] ProblemSet2.dpr(11): E2003 Undeclared identifier: 'TFrmMain'" The peculiar thing is, if I copy all the code and design data and close the project and open a new project and copy&paste both back it will run just fine. I can't find what I am doing wrong. Any help would be appreciated. Below the code and the design data:

I think you are having issues for exactly the way you have been re-creating your project, via copy and paste.

In the .dpr it has

Application.CreateForm(TFormMain, FormMain);

but the form itself has

TfrmMain = class(TForm)

as the main form

TFormMain versus TfrmMain

If you are going to change the name of the form, change it in the object inspector, so Delphi can manage all the references to it (Also, Delphi does not manage it if you use the Form's name in code you produce). If you copy and paste, it cannot...

I think you are having issues for exactly the way you have been re-creating your project, via copy and paste.

In the .dpr it has

Application.CreateForm(TFormMain, FormMain);

but the form itself has

TfrmMain = class(TForm)

as the main form

TFormMain versus TfrmMain

hmm yes I accidentally took the .dpr from the wrong version.
I have checked all the names numerous times.

The problem starts without using copy&paste. Let say I start a new project and unit and write a bit of code and then test it. It will compile and run fine. However, when I write a bit of new code, it won't compile giving the error mentioned above. I haven't changed the form name. This problem occurs in multiple projects, however, not in every. Could it have something to do with the way I save. Save All --> Save project?

Correct designs ever created, usually not easy because everyone can have characteristics which differ from one another.

I advise you to always generate a standard design, and copy your entire folder to a new project and thus change only what you want in the new project.

The command "SAVE AS" server, however, will have to do for all files in the old project to the new one. So it's a bit tricky. (But if you have a tool for that, everything is solved) -> Copy the entire folder is faster and gives the same desired effect.

My opinion: Start a new project and do the test copy to a new project and compile it!

Another thing, some words (even if not exclusively a language - as "result") should not be used, because in versions may become prohibited its use on certain occasions.

The "result" is used to accommodate the results of functions and NOT procedures (which allows it to be used in procedures, however, do not believe its use is indicated)

example:

MyFuncSum2plus2 function: integer:
begin
result: = 2 + 2;
end;

The "result" have a function as the word "self" for the components, or be, refer to the function itself. So you could write something like:

result:= 2 + 2; OR myFuncSum2plus2 := 2 + 2;

In a procedure, it would not make sense and could confuse your use, then you could choose a variable with a different name, with: myResultWaited (Delphi [Paschal] does not use this name for your own use.

In your case, you need not call for any variable to concatenate two strings:

First of all, thank you for the advice. I see the point made previously. My mistake. I will start to use a general design.
Concerning the point you made about using "result" thank you. I was unaware that this might cause some problems. However the style used mimics the style our professor uses in the course. Nevertheless, I will use your advice in future projects.

Originally Posted by emailx45

In your case, you need not call for any variable to concatenate two strings:

First of all, thank you for the advice. I see the point made previously. My mistake. I will start to use a general design.
Concerning the point you made about using "result" thank you. I was unaware that this might cause some problems. However the style used mimics the style our professor uses in the course. Nevertheless, I will use your advice in future projects.