Welcome, Guest
Username: Password: Remember me
General discussions, feature requests for CodeTyphon Project and discussions that don't fit in any of the other specific CodeTyphon forum categories.
  • Page:
  • 1

TOPIC:

strange behavior 7 years 10 months ago #10545

  • Marcin W.
  • Marcin W.'s Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 20
  • Thank you received: 0
I will try this on an example:

form:
object Form1: TForm1
  Left = 385
  Height = 300
  Top = 111
  Width = 450
  Caption = 'Form1'
  ClientHeight = 300
  ClientWidth = 450
  DesignTimePPI = 120
  LCLVersion = '6.0'
  object Edit1: TEdit
    Left = 168
    Height = 28
    Top = 72
    Width = 80
    TabOrder = 0
    Text = 'Edit1'
  end
  object Edit2: TEdit
    Left = 168
    Height = 28
    Top = 120
    Width = 80
    TabOrder = 1
    Text = 'Edit2'
  end
  object Button1: TButton
    Left = 173
    Height = 25
    Top = 176
    Width = 75
    Caption = 'Button1'
    OnClick = Button1Click
    TabOrder = 2
  end
end

unit:
TForm1 = class(TForm)
  Button1 : TButton; 
  Edit1 : TEdit;
  Edit2 : TEdit;
  procedure Button1Click(Sender : TObject);

  private
  public
end;

Nothing unusual. Than add another TEdit to a TForm, but just in code, not by droppping on the form.
TForm1 = class(TForm)
  Button1 : TButton; 
  Edit1 : TEdit;
  Edit2 : TEdit;
  troll : TEdit;
  procedure Button1Click(Sender : TObject);

  private
  public
end;

Program compiles without any errors. In Delphi i have dialog warning.

Please Log in or Create an account to join the conversation.

strange behavior 7 years 10 months ago #10550

  • Matis A.
  • Matis A.'s Avatar
  • Away
  • Moderator
  • Moderator
  • Posts: 1132
  • Thank you received: 170
I don't see any problem
"troll : TEdit;" is class TForm1 global variable

Can you attach a sample project ?
PilotLogic Core Programmer

Please Log in or Create an account to join the conversation.

Last edit: by Matis A..

strange behavior 7 years 10 months ago #10551

  • Marcin W.
  • Marcin W.'s Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 20
  • Thank you received: 0
On this extremaly simple example maybe there is no problem.
Few days ago I lost hole day looking for an error. Somehow, when I put TEdit on a form, the object didnt appear on a form, but CT put declaration to the code, as expected. I didnt notice this at that moment, because the form was very complicated. Thousand lines below TForm declaration, I was trying do something like this:
EditAddress1.Text := '';    -> OK
EditAddress2.Text := '';    -> error raises
and got "Access violation" error.

So, the point is, when you put some controls to the form, your intention is to use them later. Delphi "knows" this. So I'm asking CT creators to make such warnings. As dialogs, not just rows in log window.

greetings
Marcin

Please Log in or Create an account to join the conversation.

Last edit: by Marcin W.. Reason: typo

strange behavior 7 years 10 months ago #10552

  • Marcin W.
  • Marcin W.'s Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 20
  • Thank you received: 0
As an sample project see attachment.
Attachments:

Please Log in or Create an account to join the conversation.

strange behavior 7 years 10 months ago #10553

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Offline
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
  • Posts: 4540
  • Thank you received: 1117
No no Sir
and CT "knows" then you put a component to a form
visual creating,
but, you must "initialize" your variables, in your case troll : TEdit

procedure TForm1.FormCreate(Sender: TObject);
begin
  troll := TEdit.Create(self);
  troll.Parent:=self;

//etc...
//  troll.SetBounds(0,0,100,100);
//  troll.Color:=clred;
//etc...

end;
PilotLogic Architect and Core Programmer

Please Log in or Create an account to join the conversation.

Last edit: by Sternas Stefanos.

strange behavior 7 years 10 months ago #10554

  • Marcin W.
  • Marcin W.'s Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 20
  • Thank you received: 0
I think we have a misunderstanding here.

You write:

procedure TForm1.FormCreate(Sender: TObject);
begin
  troll := TEdit.Create(self);
  troll.Parent:=self;

Sir, my intention was NOT to add a visual component manualy, but in usual way, just by putting component on a form.

In my case, when I put a visual component, CT:
  1. added declaration to PAS file
  2. did not add information to LFM file
So project compiles without any errors, because syntax is correct.


I am asking you to make changes, when CT will behave like Delphi:

This code compiles in delphi with dialog warning
"Field Edit2 does not have a corresponding component. Remove the declaration?"
// Edit2 is not put on a form
  TForm2 = class(TForm)
    Edit2: TEdit;
  private
    { Private declarations }
  public
    { Public declarations }
  end;

And this code compiles without such warning
// Edit2 is not put on a form
  TForm2 = class(TForm)
  private
    { Private declarations }
    Edit2: TEdit;   // declaration moved to private section
  public
    { Public declarations }
  end;

Please Log in or Create an account to join the conversation.

strange behavior 7 years 10 months ago #10555

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Offline
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
  • Posts: 4540
  • Thank you received: 1117
Sir
1) We (5 programmers here) don't think that the Delphi dialog warning is correct

2) In Object Pascal you can write variables and in global session of a Form :)

so no problem :)

Please, do NOT forget Delphi syntax is NOT 100% the same with Object Pascal syntax,
and we not want to be the same, we are NOT from Delphi planet... :lol:
PilotLogic Architect and Core Programmer

Please Log in or Create an account to join the conversation.

Last edit: by Sternas Stefanos.

strange behavior 7 years 10 months ago #10556

  • Marcin W.
  • Marcin W.'s Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 20
  • Thank you received: 0

so no problem :)


I am not sure, I good understand you. When you drop a visual component on a form in design mode, and CT does not put information about this to LFM file - this is not a problem?

As for syntax, in this case, there are no differences between ObjectPascal and Delphi. Both samples I wrote in my previous post can be compiled in Delphi, checked. The only difference lies in the warning.

I use Delphi and Lazarus for many years, and don't remember if somebody puts in TForm a VISUAL COMPONENT declaration in the begining (above private section), with an intention to create it later MANUALLY in code. All components above private section are supposed default created when form variable is created. Imagine situation when your form has tens of visual components. Will you check all of them if they have corresponding information in LFM file? Is it not simplier to warn programmer?

I do realize that you are not from Delphi planet. But, maybe better attitude is to implement good ideas from other IDE's, rather than to try be different?

Please Log in or Create an account to join the conversation.

  • Page:
  • 1