Recent

Author Topic: Problem créate form  (Read 3858 times)

Fabius

  • New Member
  • *
  • Posts: 48
Problem créate form
« 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

wp

  • Hero Member
  • *****
  • Posts: 9025
Re: Problem créate form
« Reply #1 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.
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

Fabius

  • New Member
  • *
  • Posts: 48
Re: Problem créate form
« Reply #2 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 ...

devEric69

  • Hero Member
  • *****
  • Posts: 644
Re: Problem créate form
« Reply #3 on: October 19, 2021, 04:01:45 pm »
At the end, there should be a uSupercomptes.pas file, that should start with "unit uSupercomptes;"
« Last Edit: October 19, 2021, 04:06:20 pm by devEric69 »
use: Linux 64 bits (Ubuntu 20.04 LTS).
Lazarus version: 2.0.4 (svn revision: 62502M) compiled with fpc 3.0.4 - fpDebug \ Dwarf3.

Fabius

  • New Member
  • *
  • Posts: 48
Re: Problem créate form
« Reply #4 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 !


devEric69

  • Hero Member
  • *****
  • Posts: 644
Re: Problem créate form
« Reply #5 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.
« Last Edit: October 19, 2021, 06:07:30 pm by devEric69 »
use: Linux 64 bits (Ubuntu 20.04 LTS).
Lazarus version: 2.0.4 (svn revision: 62502M) compiled with fpc 3.0.4 - fpDebug \ Dwarf3.

wp

  • Hero Member
  • *****
  • Posts: 9025
Re: Problem créate form
« Reply #6 on: October 19, 2021, 06:12:40 pm »
This is the way I do it:
  • Add a new form
  • I decide what the form should be named, in your case: "SuperComptes" (normally I'd add "Form" to indicated that the class is a form, but anyway...)
  • I save the form. The filename MUST NOT BE EQUAL to the name of the form. To distinguish the names, many people put a "u" (for "unit") in front of the filename -> save as "uSuperComptes", or add a "unit" to the form name --> "SuperComptesUnit". There are many possibilities.
  • This works, for sure.
« Last Edit: October 19, 2021, 07:33:04 pm by wp »
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

Fabius

  • New Member
  • *
  • Posts: 48
Re: Problem créate form
« Reply #7 on: October 20, 2021, 10:42:08 am »
I have make the procedure to WP ,

Fabius

  • New Member
  • *
  • Posts: 48
Re: Problem créate form
« Reply #8 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 ....

Fabius

  • New Member
  • *
  • Posts: 48
Re: Problem créate form
« Reply #9 on: October 20, 2021, 10:46:20 am »
inspector

Fabius

  • New Member
  • *
  • Posts: 48
Re: Problem créate form
« Reply #10 on: October 20, 2021, 10:47:51 am »
Error duplicate !

GetMem

  • Hero Member
  • *****
  • Posts: 3512
Re: Problem créate form
« Reply #11 on: October 20, 2021, 11:38:43 am »
@Fabius

Please post your project as attachment, source only, there is a 250 kB limit.

devEric69

  • Hero Member
  • *****
  • Posts: 644
Re: Problem créate form
« Reply #12 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 or Camel case, for sanitary maintenance of your code and to be sensitive to homonyms, AMHO.

« Last Edit: October 20, 2021, 12:18:38 pm by devEric69 »
use: Linux 64 bits (Ubuntu 20.04 LTS).
Lazarus version: 2.0.4 (svn revision: 62502M) compiled with fpc 3.0.4 - fpDebug \ Dwarf3.

dbannon

  • Hero Member
  • *****
  • Posts: 1676
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Problem créate form
« Reply #13 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
Lazarus 2, Linux (and reluctantly Win10, OSX)
My Project - https://github.com/tomboy-notes/tomboy-ng

Fabius

  • New Member
  • *
  • Posts: 48
Re: Problem créate form
« Reply #14 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

 

TinyPortal © 2005-2018