Lazarus

Using the Lazarus IDE => Designer => Topic started by: Fabius on October 19, 2021, 11:56:07 am

Title: Problem créate form
Post by: Fabius on October 19, 2021, 11:56:07 am
I have a projet width 10 form , compile ok !

I want append a new form , and probleme

Not find the form ? no compile

lazarus 2.20

where the probleme ?

Thank
Title: Re: Problem créate form
Post by: wp on October 19, 2021, 12:12:45 pm
The unit has the same name as the default instance of the form. Save the unit as "SuperComptesUnit", or "uSuperComptes" - anything different from "SuperComptes". Or name the form class as "TSuperComptesForm" so that its default instance will be named "SuperComptesForm" - then the unit keep its name.
Title: Re: Problem créate form
Post by: Fabius on October 19, 2021, 03:03:57 pm
Thank you for the answer , :)

I did nothing other than use the creation of form

I tried several solutions to change the names ...., I can't find the solution

Looks like he remembers the names ...

I will try again ...
Title: Re: Problem créate form
Post by: devEric69 on October 19, 2021, 04:01:45 pm
At the end, there should be a uSupercomptes.pas file, that should start with "unit uSupercomptes;"
Title: Re: Problem créate form
Post by: Fabius on October 19, 2021, 05:10:27 pm
OK ....
But

I just enter the name with the idea, nothing else, the idea should enter the correct names and not mix it up

I only fill in the name in the inspector for the form!


Compilation du projet - Cible : project1.exe : Code de sortie 1 - Erreurs : 1 - Conseils : 1
formliasses.pas(19,3) Error: Duplicate identifier "formliasses"
formliasses.pas(19,14) Hint: Identifier already defined in formliasses.pas at line 5


The name it's by ide !

Title: Re: Problem créate form
Post by: devEric69 on October 19, 2021, 06:03:02 pm
OK ....
I just enter the name with the idea, nothing else, the idea should enter the correct names and not mix it up

Yes, that's right.

I only fill in the name in the inspector for the form!

It may not be enough. There is an option in the IDE that says whether it's case sensitive or not ("usupercomptes.pas" == "uSupercomptes.pas", yes or not?).

So, first, AMHO, it's better to to make (be sure) Lazarus is case sensitive with filenames.
After, you have to fight a bit with the IDE :) ==> save your source code in a aside *.txt file, and really, AMHO, recreate a new "unit 1". Then, save it (unit 1) as uSupercomptes.pas. Then try a uses uSupercomptes; from another already working and existing unit, ... until it works (and it will work). Then paste the saved code inside your new working uSupercomptes.pas.
Title: Re: Problem créate form
Post by: wp on October 19, 2021, 06:12:40 pm
This is the way I do it:
Title: Re: Problem créate form
Post by: Fabius on October 20, 2021, 10:42:08 am
I have make the procedure to WP ,
Title: Re: Problem créate form
Post by: Fabius on October 20, 2021, 10:45:41 am
The name of form are formliasse.lfm and pas  , but the name form from inspector are liasseform ....
Title: Re: Problem créate form
Post by: Fabius on October 20, 2021, 10:46:20 am
inspector
Title: Re: Problem créate form
Post by: Fabius on October 20, 2021, 10:47:51 am
Error duplicate !
Title: Re: Problem créate form
Post by: GetMem on October 20, 2021, 11:38:43 am
@Fabius

Please post your project as attachment, source only, there is a 250 kB limit.
Title: Re: Problem créate form
Post by: devEric69 on October 20, 2021, 11:54:49 am
You have 2 different concepts, named with the same name, i.e. you have still homonyms!!? ==> a unit called formliasses.pas AND a global variable called var formliasses: ...\... ==> rename your unit as uFormliasses.pas and its first line (header) must be unit uFormliasses; .


Please use "case sensitive" for your files naming convention (it's an option in Lazarus IDE), and for your variables, etc... And please, take a look at what is called Hungarian notation (https://wiki.freepascal.org/Hungarian_notation) or Camel case, for sanitary maintenance of your code and to be sensitive to homonyms, AMHO.

Title: Re: Problem créate form
Post by: dbannon on October 20, 2021, 12:08:51 pm
Fabius, think you need to understand whats happening here.  There are three things in play -

Unit name.  That relates to all the content in one source file, it appears near the top of the file, on a line that says "unit unitname;".  The unit name is also used for the pas file and if there  is one, the lfm file.  To change it, you should, in the source editor, click File and Save As. The ide will save the editor content in the new file name and change the unit name.

Type Name. In the unit, you will probably have one or more declared Types.  Its a good idea to make a type name start with a capital T. In your case it looks like the Types you are dealing with are TForm dependents and are used to define what a form might look like.  One way to change a Type name (without a lot of typing) is to highlight the first use of the Type name (remember, it starts with T) and press F2, change all occurrences.

Variable Name. A variable is always of a particular Type and you can have one or more of them.  In your case here, the Type is a TForm descendant and that means each variable of that Type represents exactly one visible (or invisible) form.  You should change a TForm type variable using the Object Inspector, Name.

Three different things, they are have different uses and all are changed in different ways. And cannot have the same name else the compiler will not understand which one you are talking about.

When you make a new form in the IDE, it helps you by giving those three different things default names, eg Unit2, TForm2 and Form2.  Good programming requires you to change those names to something that will help you remember what they are for. If the form is about "liasse", maybe its as WP suggested, the unit changes from Unit2 to uLiasse, the Type from TForm2 to TLiasse and the form itself changes from Form2 to Liasse, or maybe FormLiasse ?  Use the IDE functions mentioned above to change them as soon as you add the new form to your project.

Davo
Title: Re: Problem créate form
Post by: Fabius on October 20, 2021, 05:41:17 pm
Thank you for your help ;)

I ended up making it work

But I don't understand why this problem with unit names

cordially to all ;D
Title: Re: Problem créate form
Post by: devEric69 on October 20, 2021, 05:53:23 pm
Well done!
Title: Re: Problem créate form
Post by: dbannon on October 21, 2021, 02:16:05 am
....
But I don't understand why this problem with unit names

Do you mean you don't understand why you cannot use the same name for different things ?  Or you don't understand that they are different things ?  I think its important that you do try to understand these matters, you will have a lot of problems (with any programming language) as long as you have not fully grasped the ideas there.

Maybe re-read my long and boring post and perhaps come back with just what part is not clear ?

Davo

TinyPortal © 2005-2018