Recent

Author Topic: Question - Maybe Just Maybe  (Read 4131 times)

JLWest

  • Hero Member
  • *****
  • Posts: 853
Question - Maybe Just Maybe
« on: April 03, 2018, 11:06:53 pm »
I haven't tested this yet but I think here is what is going on with the Compiler renaming Issue.

I was working on the project and checking this Process Monitor thing.
I need to add a label which I did.
Then a second label.
In changing from viewing the Process Monitor and adding the label focus changed
from the label to the windowTForm2. I almost renamed Form2 to lblRC1320. Then I noticed it was the window and I clicked on the label and renamed it.

 But what if I hadn't caught it and renamed the Form and hit the compile button.

I'll test it.

FPC 3.2.0, Lazarus IDE v2.0.4
 Windows 10 Pro 32-GB
 Intel i7 770K CPU 4.2GHz 32702MB Ram
GeForce GTX 1080 Graphics - 8 Gig
4.1 TB

Bart

  • Hero Member
  • *****
  • Posts: 3911
    • Bart en Mariska's Webstek
Re: Question - Maybe Just Maybe
« Reply #1 on: April 03, 2018, 11:17:35 pm »
As many people have pointed out to you: this is NOT a compiler issue.
The compiler does NOT change your sourcecode.
If you do not believe this, please examine the sourcode of the compiler: NOWHERE does the compiler write to your sourcecode files.

Renaming an identifier inside the Lazarus IDE sometimes can give unexpected results, I even told you there was already a bugreport about that.

And it really is up to you, to take care what control has focus if you want to rename it, really.

Also, there is NO need to keep opening different threads in this forum about the exact same problem you experience.

Bart

JLWest

  • Hero Member
  • *****
  • Posts: 853
Re: Question - Maybe Just Maybe
« Reply #2 on: April 03, 2018, 11:32:34 pm »
Is that your standard "I told you so!" or you did it just for me.
FPC 3.2.0, Lazarus IDE v2.0.4
 Windows 10 Pro 32-GB
 Intel i7 770K CPU 4.2GHz 32702MB Ram
GeForce GTX 1080 Graphics - 8 Gig
4.1 TB

lainz

  • Hero Member
  • *****
  • Posts: 3709
  • Leandro Diaz
Re: Question - Maybe Just Maybe
« Reply #3 on: April 03, 2018, 11:43:26 pm »
As many people have pointed out to you: this is NOT a compiler issue.
The compiler does NOT change your sourcecode.
If you do not believe this, please examine the sourcode of the compiler: NOWHERE does the compiler write to your sourcecode files.

Renaming an identifier inside the Lazarus IDE sometimes can give unexpected results, I even told you there was already a bugreport about that.

And it really is up to you, to take care what control has focus if you want to rename it, really.

Also, there is NO need to keep opening different threads in this forum about the exact same problem you experience.

Bart

Is a troll. Is laughing of all the forum.

There are no image uploads in his account, is a troll.
https://imgur.com/user/JLWest/submitted

Already reported to moderators.


« Last Edit: April 04, 2018, 01:47:13 am by lainz »

JLWest

  • Hero Member
  • *****
  • Posts: 853
Re: Question - Maybe Just Maybe
« Reply #4 on: April 04, 2018, 12:37:39 am »
As many people have pointed out to you: this is NOT a compiler issue.
The compiler does NOT change your sourcecode.
If you do not believe this, please examine the sourcode of the compiler: NOWHERE does the compiler write to your sourcecode files.

Renaming an identifier inside the Lazarus IDE sometimes can give unexpected results, I even told you there was already a bugreport about that.

And it really is up to you, to take care what control has focus if you want to rename it, really.

Also, there is NO need to keep opening different threads in this forum about the exact same problem you experience.

Bart

Is a troll. Is laughing of all the forum.

There are no image uploads in his account, is a troll.
https://imgur.com/user/JLWest/submitted

Already reported to moderators.

Lainz Sorry you think that. I'm NOT a troll, This  was an honest post.

Stop and think about what your saying. Look at all the work I would have to do to pull this off.
Check my past post. I have been writing Free Pascal for maybe 3 months.

I'm 74 years old, retired and trying to learn Free Pascal.

I retired as a VP of a major US corporation and I'm willing to prove that by sending you a copy of my last business card from that corporation.



Dose your accusation really add up.

.
FPC 3.2.0, Lazarus IDE v2.0.4
 Windows 10 Pro 32-GB
 Intel i7 770K CPU 4.2GHz 32702MB Ram
GeForce GTX 1080 Graphics - 8 Gig
4.1 TB

JLWest

  • Hero Member
  • *****
  • Posts: 853
Re: Question - Maybe Just Maybe
« Reply #5 on: April 04, 2018, 12:47:35 am »
By the way, I think there is a bug.

It's with the IDE.

If you rename a Form from Tform2 to lblRC1302 or anything it's valid for the IDE to rename all you're procedures (TForm2.ProcedureXXX to lblRC1302.ProcedureXXX).

The IDE renamed the Class name in the Object Inspector.

That to me is a bug.


FPC 3.2.0, Lazarus IDE v2.0.4
 Windows 10 Pro 32-GB
 Intel i7 770K CPU 4.2GHz 32702MB Ram
GeForce GTX 1080 Graphics - 8 Gig
4.1 TB

taazz

  • Hero Member
  • *****
  • Posts: 5365
Re: Question - Maybe Just Maybe
« Reply #6 on: April 04, 2018, 01:02:06 am »
By the way, I think there is a bug.

It's with the IDE.

If you rename a Form from Tform2 to lblRC1302 or anything it's valid for the IDE to rename all you're procedures (TForm2.ProcedureXXX to lblRC1302.ProcedureXXX).

The IDE renamed the Class name in the Object Inspector.

That to me is a bug.
erm that's by design form's name and type are linked makes things easier to find.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

molly

  • Hero Member
  • *****
  • Posts: 2345
Re: Question - Maybe Just Maybe
« Reply #7 on: April 04, 2018, 01:04:54 am »
By the way, I think there is a bug.

If you rename a Form from Tform2 to lblRC1302 or anything it's valid for the IDE to rename all you're procedures (TForm2.ProcedureXXX to lblRC1302.ProcedureXXX).

The IDE renamed the Class name in the Object Inspector.

That to me is a bug.
Uhm.... unless i misunderstood your words: you changed the name of your class(type) and believe the object inspector should not reflect this change ? If that is true then i believe you misunderstood the purpose of the object inspector. Object inspector should alway be in sync with your source-code (and vice versa) otherwise such a 'inspector' would be pointless.

edit: i fear the day you figure out (if you haven't already) how to edit your form's text. I would advise to stay away from that as far as possible until you have a better understanding of the GUI designer and how the object inspector works in conjunction with the source-code.
« Last Edit: April 04, 2018, 01:17:07 am by molly »

lainz

  • Hero Member
  • *****
  • Posts: 3709
  • Leandro Diaz
Re: Question - Maybe Just Maybe
« Reply #8 on: April 04, 2018, 01:46:52 am »
I'm 74 years old, retired and trying to learn Free Pascal.

Sorry. I retire my words.

But I think now it makes more sense, not just for me but for all.

And again, please learn SVN or GIT, it will help you a lot as I already pointed, so you can revert changes easily.
« Last Edit: April 04, 2018, 01:50:55 am by lainz »

JLWest

  • Hero Member
  • *****
  • Posts: 853
Re: Question - Maybe Just Maybe
« Reply #9 on: April 04, 2018, 02:11:03 am »
By the way, I think there is a bug.

If you rename a Form from Tform2 to lblRC1302 or anything it's valid for the IDE to rename all you're procedures (TForm2.ProcedureXXX to lblRC1302.ProcedureXXX).

The IDE renamed the Class name in the Object Inspector.

That to me is a bug.
Uhm.... unless i misunderstood your words: you changed the name of your class(type) and believe the object inspector should not reflect this change ? If that is true then i believe you misunderstood the purpose of the object inspector. Object inspector should alway be in sync with your source-code (and vice versa) otherwise such a 'inspector' would be pointless.

edit: i fear the day you figure out (if you haven't already) how to edit your form's text. I would advise to stay away from that as far as possible until you have a better understanding of the GUI designer and how the object inspector works in conjunction with the source-code.

No not the class type.

I didn't explain it well but here is what I think

In the Object Inspector if you click on  Form2 it shows at the top Form2 : TForm2.

Form2 is the name and TForm2 is the class. (Is that Correct?)


If you go down and rename the form to Config the Object Inspector will show what?

Will it show Config : TConfig.

I the case of miss labeling the form name to lblRC1302 the IDE renamed the form to
lblRC1302 : TlblRC1302

If that's what it's suppose to do then it's not bug.






FPC 3.2.0, Lazarus IDE v2.0.4
 Windows 10 Pro 32-GB
 Intel i7 770K CPU 4.2GHz 32702MB Ram
GeForce GTX 1080 Graphics - 8 Gig
4.1 TB

taazz

  • Hero Member
  • *****
  • Posts: 5365
Re: Question - Maybe Just Maybe
« Reply #10 on: April 04, 2018, 02:36:13 am »
lets start with basics.
1) Name is a property of a class eg
Code: Pascal  [Select][+][-]
  1. type
  2.   TMyObject = class
  3.   private
  4.     FName :String;
  5.   public
  6.     Property Name:string read FName write FName;
  7.   end;
  8.  
That is all a name is.
2) in order to make things intuitive the designer (IDE) links the name with the variable name it created when you dropped your control on the form (label, edit etc)
eg
I can create any control in any variable and give it any name I like
Code: Pascal  [Select][+][-]
  1. procedure Test;
  2. var
  3.   lblTest : TLabel;
  4.   Test2 :TLabel;
  5. begin
  6.   lblTest :=tlabel.Create(nil);
  7.   test2 := TLabel.Create(nil);
  8.   lblTest.Name := 'QuoteOfTheDay';
  9.   Test2.Name :='lblTest';
  10. end;
  11.  
There is no rule linking the name of a component to the name of the variable or the name of the type.
Now imagine that you have 10 labels on a form all the variables that hold them are name label1..10 and the names are different. how would you know which variable has which name? The IDE makes sure that the variable name and the value in the name property of the control are the same. that makes things easy to use. Name a label as lblAirforce1 and you get a variable named lblAirForce1 that holds an instance of that label to use in your code.

So far so good.


Now there are special cases of controls which are known collectively as containers* because you can place other controls in them and they are bound their boundaries and properties and there is a smaller subgroup of those containers that are used at design time to create compound controls, in short the compound controls, aka controls that incorporate other controls in them, are only 3 1) Datamodule (non visual) 2)Form and 3)Frame. Those control are special in that, they offer a single control, that encompasses all the functionality their enclosed controls have given, as single control, for those controls the IDE links the name of the control not only with the variable name but the class name as well. It makes things easier to create, lets assume that you changed the name of the form2 to AirplaneEditor. How would you create that form in code if you need to?
Code: Pascal  [Select][+][-]
  1. var
  2.   MyEditor : TForm2;
  3. begin
  4.   MyEditor := TForm2.Create(nil);
  5.  
or
Code: Pascal  [Select][+][-]
  1. var
  2.   MyEditor : TAirplaneEditor;
  3. begin
  4.   MyEditor := TAirplaneEditor.Create(nil);
  5.  

what is more intuitive to you?

For me the second one fills more natural and removes all doubt of which form I created.
So in the cases of compound control creators the IDE will rename not only the variable but the type as well to make it clear when used.

*Some Examples of container controls that are not used to create compound controls at design time are the TScrollbox, TPanel and TPagecontrol.

Hope this clears any misunderstandings if not fill free to ask more questions.

PS:
the Term compound controls is not official I'm using it to describe the mentioned group of controls as far as I know I'm alone in that use.
« Last Edit: April 04, 2018, 02:56:20 am by taazz »
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

molly

  • Hero Member
  • *****
  • Posts: 2345
Re: Question - Maybe Just Maybe
« Reply #11 on: April 04, 2018, 02:37:12 am »
I didn't explain it well but here is what I think
It could just as well have been me as English isn't native for me.

thank you for re-phrasing your description.

Quote
In the Object Inspector if you click on  Form2 it shows at the top Form2 : TForm2.

Form2 is the name and TForm2 is the class. (Is that Correct?)
That is correct. Name of the form vs name of the class (confusion appeared on my part as TForm2 is also known as the name of the class -> classname).

Quote
If you go down and rename the form to Config the Object Inspector will show what?

Will it show Config : TConfig.
That is correct.

Quote
I the case of miss labeling the form name to lblRC1302 the IDE renamed the form to
lblRC1302 : TlblRC1302
That is also correct.

Quote
If that's what it's suppose to do then it's not bug.
Yes, that is suppose to happen (e.g. it is by design), therefor taazz' answer was/is correct.

There is a (hidden) relation between the name of your form and the name of the class to keep them in sync (added capital T using the name of the form). The purpose is as explained by taazz in his posts.

If you are not aware of this feature then this might work counterproductive and/or confusing for you.

Note that this is feature is 'present' for form/module variables only, not on/for the average component placed on your form/module (as the type can't change there). The form variable declaration is special in that regards (referred to by taazz' post as container).
« Last Edit: April 04, 2018, 02:42:38 am by molly »

JLWest

  • Hero Member
  • *****
  • Posts: 853
Re: Question - Maybe Just Maybe Thanks all for the Help
« Reply #12 on: April 04, 2018, 04:21:24 am »
It's is clearer, but Free Basic is still new to me.

I did the test and I wan inadvertently renaming TForm2 tinkling I was editing a label name. So I went bacK into the code and made all of the changes, compiled and ran.

Thru all of this I learned a lot. How to fix my own code in some instances (quite a few actually).

Sorry to have put everyone thru this.

But thanks for all the Help.

FPC 3.2.0, Lazarus IDE v2.0.4
 Windows 10 Pro 32-GB
 Intel i7 770K CPU 4.2GHz 32702MB Ram
GeForce GTX 1080 Graphics - 8 Gig
4.1 TB

taazz

  • Hero Member
  • *****
  • Posts: 5365
Re: Question - Maybe Just Maybe Thanks all for the Help
« Reply #13 on: April 04, 2018, 04:31:42 am »
It's is clearer, but Free Basic is still new to me.
still trolling I see :P
I did the test and I wan inadvertently renaming TForm2 tinkling I was editing a label name. So I went bacK into the code and made all of the changes, compiled and ran.

Thru all of this I learned a lot. How to fix my own code in some instances (quite a few actually).

Sorry to have put everyone thru this.

But thanks for all the Help.
take one step at a time and make sure to always describe what you did what did you expect to happen and what happened when asking for help. That will remove any and all doubts of what is what.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

Bart

  • Hero Member
  • *****
  • Posts: 3911
    • Bart en Mariska's Webstek
Re: Question - Maybe Just Maybe
« Reply #14 on: April 04, 2018, 01:13:32 pm »
If you rename a Form from Tform2 to lblRC1302 or anything it's valid for the IDE to rename all you're procedures (TForm2.ProcedureXXX to lblRC1302.ProcedureXXX).

The IDE renamed the Class name in the Object Inspector.

That to me is a bug.

I agree with you, to me that doesn't make sense at all.

In contrats, if you select "Form1" in the sourcode, at the place where the variable is declared (var Form1: TForm1), then press Ctrl+Shit+E (Find or rename identifier) and then change the name to e.g. Form123, the classname isn't changed.

Maybe it is a Delphi compatibility issue?

Bart

 

TinyPortal © 2005-2018