The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages - More
> Delphi Programming
|
Delphi XE2 16 Compiling problem
Discuss Delphi XE2 16 Compiling problem in the Delphi Programming forum on Dev Shed. Delphi XE2 16 Compiling problem Delphi Programming forum discussing Delphi related topics including Kylix, C++ Builder, and more. Delphi is a high-performance language, originally based on the PASCAL language.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

October 30th, 2012, 06:01 PM
|
|
Registered User
|
|
Join Date: Oct 2012
Posts: 5
Time spent in forums: 1 h 4 m 21 sec
Reputation Power: 0
|
|
|
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:
Code:
Code:
unit ProblemSet2FirstUnit;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
type
TfrmMain = class(TForm)
buttonforclose: TButton;
leftgroup1: TGroupBox;
group1label1: TLabel;
group1Label2: TLabel;
group1Label3: TLabel;
group1textbox1: TEdit;
group1textbox2: TEdit;
group1button: TButton;
group1MemoBox: TMemo;
group1clearbutton: TButton;
procedure buttonforcloseClick(Sender: TObject);
procedure group1buttonClick(Sender: TObject);
procedure group1clearbuttonClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
FrmMain: TFrmMain;
implementation
{$R *.dfm}
procedure TFrmMain.buttonforcloseClick(Sender: TObject);
begin
Close;
end;
procedure TFrmMain.group1buttonClick(Sender: TObject);
var
result:string;
begin
result := group1textbox1.text + group1textbox2.text;
group1MemoBox.Lines.Add(result);
end;
procedure TFrmMain.group1clearbuttonClick(sender: TObject);
begin
group1MemoBox.Lines.Clear;
end;
end.
Design Code:
Code:
object frmMain: TfrmMain
Left = 0
Top = 0
Caption = 'Tutorial Class 2: Variables'
ClientHeight = 949
ClientWidth = 1468
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object buttonforclose: TButton
Left = 672
Top = 900
Width = 75
Height = 25
Caption = 'Close'
TabOrder = 0
OnClick = buttonforcloseClick
end
object leftgroup1: TGroupBox
Left = 8
Top = 0
Width = 409
Height = 193
Caption = 'part 1: String Concatenation'
TabOrder = 1
object group1label1: TLabel
Left = 64
Top = 51
Width = 52
Height = 13
Caption = 'First String'
end
object group1Label2: TLabel
Left = 272
Top = 51
Width = 66
Height = 13
Caption = 'Second String'
end
object group1Label3: TLabel
Left = 11
Top = 107
Width = 30
Height = 13
Caption = 'Result'
end
object group1textbox1: TEdit
Left = 11
Top = 24
Width = 190
Height = 21
TabOrder = 0
end
object group1textbox2: TEdit
Left = 240
Top = 24
Width = 153
Height = 21
TabOrder = 1
end
object group1button: TButton
Left = 144
Top = 51
Width = 75
Height = 25
Caption = 'Concatenate'
TabOrder = 2
OnClick = group1buttonClick
end
object group1MemoBox: TMemo
Left = 64
Top = 82
Width = 329
Height = 63
ScrollBars = ssVertical
TabOrder = 3
end
object group1clearbutton: TButton
Left = 176
Top = 151
Width = 75
Height = 25
Caption = 'Clear'
TabOrder = 4
OnClick = group1clearbuttonClick
end
end
end
|

October 31st, 2012, 04:21 PM
|
|
Registered User
|
|
Join Date: Oct 2012
Posts: 5
Time spent in forums: 1 h 4 m 21 sec
Reputation Power: 0
|
|
|
No one
No one knows what could be the issue?
|

October 31st, 2012, 10:46 PM
|
|
Contributing User
|
|
Join Date: Jan 2006
Location: Carlsbad, CA
|
|
|
The error message says that the problem is in ProblemSet2.dpr but you did not post the source code for ProblemSet2.dpr
|

November 1st, 2012, 05:06 AM
|
|
Registered User
|
|
Join Date: Oct 2012
Posts: 5
Time spent in forums: 1 h 4 m 21 sec
Reputation Power: 0
|
|
Quote: | Originally Posted by clivew The error message says that the problem is in ProblemSet2.dpr but you did not post the source code for ProblemSet2.dpr |
Yes sorry, my mistake. Here is the source code
Code:
program ProblemSet2;
uses
Vcl.Forms,
ProblemSet2FirstUnit in 'ProblemSet2FirstUnit.pas' {FormMain};
{$R *.res}
begin
Application.Initialize;
Application.MainFormOnTaskbar := True;
Application.CreateForm(TFormMain, FormMain);
Application.Run;
end.
|

November 1st, 2012, 09:54 AM
|
|
Contributing User
|
|
Join Date: Jun 2008
Posts: 252
 
Time spent in forums: 2 Days 22 h 53 m 5 sec
Reputation Power: 5
|
|
|
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...
Last edited by majlumbo : November 1st, 2012 at 09:59 AM.
|

November 1st, 2012, 10:03 AM
|
|
Registered User
|
|
Join Date: Oct 2012
Posts: 5
Time spent in forums: 1 h 4 m 21 sec
Reputation Power: 0
|
|
Quote: | Originally Posted by majlumbo 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?
I am sorry for the sloppiness in providing the code.
|

November 1st, 2012, 11:07 AM
|
|
Contributing User
|
|
Join Date: Sep 2008
Posts: 44
Time spent in forums: 10 h 7 m 32 sec
Reputation Power: 5
|
|
Dear friend,
Certainly, there is a discrepancy between the unit and the source (application called)!
program ProblemSet2;
uses
Vcl.Forms,
ProblemSet2FirstUnit in 'ProblemSet2FirstUnit.pas' {FormMain};
{$R *.res}
begin
Application.Initialize;
Application.MainFormOnTaskbar := True;
Application.CreateForm(TFormMain, FormMain); Application.Run;
end.
------------
type
TfrmMain = class(TForm) ...
var
FrmMain: TFrmMain;
------------------------------
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:
var
result:string;
begin
result := group1textbox1.text + group1textbox2.text;
group1MemoBox.Lines.Add(result);
Just use:
MemoX.Line.Add (group1textbox1.text + group1textbox2.text);
|

November 1st, 2012, 11:23 AM
|
|
Registered User
|
|
Join Date: Oct 2012
Posts: 5
Time spent in forums: 1 h 4 m 21 sec
Reputation Power: 0
|
|
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.
Quote: | Originally Posted by emailx45
In your case, you need not call for any variable to concatenate two strings:
var
result:string;
begin
result := group1textbox1.text + group1textbox2.text;
group1MemoBox.Lines.Add(result);
Just use:
MemoX.Line.Add (group1textbox1.text + group1textbox2.text); |
|

November 1st, 2012, 12:31 PM
|
|
Contributing User
|
|
Join Date: Sep 2008
Posts: 44
Time spent in forums: 10 h 7 m 32 sec
Reputation Power: 5
|
|
Quote: | Originally Posted by Switch46 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. |
When using XE2 or XE3, do research about LIVEBINDINGS properties:
http://www.embarcadero.com/rad-in-action/livebindings
http://docwiki.embarcadero.com/RADStudio/XE3/en/LiveBindings_in_RAD_Studio
http://www.youtube.com/watch?v=AxiZoEDY998
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|