Recent

Author Topic: [SOLVED] Custom form  (Read 20519 times)

pcurtis

  • Hero Member
  • *****
  • Posts: 951
Re: Custom form
« Reply #15 on: December 18, 2021, 05:50:59 pm »
Project templates would solve everything, but as normal it doesn't work correctly. IMHO development of Lazarus should pause a few cycles and work should taken out to iron out issues, not add more. But I'm just a user.
Windows 10 20H2
Laz 2.2.0
FPC 3.2.2

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4673
  • I like bugs.
Re: Custom form
« Reply #16 on: December 18, 2021, 05:52:10 pm »
Can I make a project template and add it there? (don't mention Tools => Project Templates. That completely sucks)
The ProjTemplates package got improved in trunk recently. It should do the job for you.
As Jamie mentioned, Tools menu only has "Project templates options ..." with one path setting. You must place the template files under that path.
I don't know why you think it sucks, but the options entry is in a wrong place. The package should register its own pane in the global Options window just like other packages do.

[Edit]
Quote
Project templates would solve everything, but as normal it doesn't work correctly.
Please test with the development version.
See: https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/38244
« Last Edit: December 18, 2021, 05:54:37 pm by JuhaManninen »
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

pcurtis

  • Hero Member
  • *****
  • Posts: 951
Re: Custom form
« Reply #17 on: December 18, 2021, 06:09:31 pm »
It sucks because it doesn't work as expected.

Try the attached template. When creating a project don't fill in anything just push OK, OK and kaboom.

If nothing is filled in defaults should be used as in new project.

Not rocket science.

Even if the fields are filled in it complains about other things.
« Last Edit: December 18, 2021, 06:34:25 pm by pcurtis »
Windows 10 20H2
Laz 2.2.0
FPC 3.2.2

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4673
  • I like bugs.
Re: Custom form
« Reply #18 on: December 18, 2021, 06:57:10 pm »
It sucks because it doesn't work as expected.
Try the attached template. When creating a project don't fill in anything just push OK, OK and kaboom.
In your project.ini file the Variables section is empty. I added this and it works:
Code: Pascal  [Select][+][-]
  1. [Variables]
  2. MAINUNIT=New filename for the Unit1.pas file
  3. TITLE=Form Caption
  4. BTNCAPTION=Button Caption

Quote
If nothing is filled in defaults should be used as in new project.
True. It could be improved. Any non-defined variable should get a sensible value, for example the variable name itself. Thus variable MAINUNIT would have value MAINUNIT. It would work and prevent crashes.
Also the initial dialog asking for project name and directory should have OK button disabled as long as the necessary info is not given.
See also the example template in the issue I linked earlier.
Patches are still welcome...
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

pcurtis

  • Hero Member
  • *****
  • Posts: 951
Re: Custom form
« Reply #19 on: December 18, 2021, 07:24:04 pm »
For me it complains the lpi file is not a lpi file
Windows 10 20H2
Laz 2.2.0
FPC 3.2.2

pcurtis

  • Hero Member
  • *****
  • Posts: 951
Re: Custom form
« Reply #20 on: December 18, 2021, 07:26:58 pm »
Do you know where the relevant code is in the ide?
Windows 10 20H2
Laz 2.2.0
FPC 3.2.2

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4673
  • I like bugs.
Re: Custom form
« Reply #21 on: December 18, 2021, 07:38:13 pm »
For me it complains the lpi file is not a lpi file
Strange. For me it compiles and runs fine. The attached screenshot shows your form in both design time and runtime. I filled the variable names when creating the project.
What is your Lazarus version?

Quote
Do you know where the relevant code is in the ide?
Code for reading the .lpi project info file? It is somewhere in the project.pp file. You can search with the error message you got.
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

pcurtis

  • Hero Member
  • *****
  • Posts: 951
Re: Custom form
« Reply #22 on: December 18, 2021, 07:44:38 pm »
2.0.12

See tag line
Windows 10 20H2
Laz 2.2.0
FPC 3.2.2

jamie

  • Hero Member
  • *****
  • Posts: 7517
Re: Custom form
« Reply #23 on: December 18, 2021, 07:51:58 pm »
2.0.12

See tag line

I see you have a space in the file path, I try to avoid those at all cost because I've seen strange things happen..

could you rename the path without the SPACE in it?
The only true wisdom is knowing you know nothing

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4673
  • I like bugs.
Re: Custom form
« Reply #24 on: December 18, 2021, 07:58:11 pm »
2.0.12
I asked you to test with the latest development version. It has an improved Project Templates package.
In 734cf1a136 I disabled the OK button while necessary information is not given.
This and the earlier important change will be merged to 2.2.
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

pcurtis

  • Hero Member
  • *****
  • Posts: 951
Re: Custom form
« Reply #25 on: December 18, 2021, 08:23:08 pm »
@jamie now i get a file not found. the directory is empty
Windows 10 20H2
Laz 2.2.0
FPC 3.2.2

jamie

  • Hero Member
  • *****
  • Posts: 7517
Re: Custom form
« Reply #26 on: December 18, 2021, 08:27:49 pm »
@jamie now i get a file not found. the directory is empty
Did you update the Template path too ?

I don't know, you may need to restart laz after those changes, they could be cached.
The only true wisdom is knowing you know nothing

pcurtis

  • Hero Member
  • *****
  • Posts: 951
Re: Custom form
« Reply #27 on: December 18, 2021, 08:33:14 pm »
@juham IMHO that logic is only half right. the filename should be the default project output directory, the project name should default to project1. that way you dont force a user to enter anything, just like when you create a new project. latter the user can save project as
Windows 10 20H2
Laz 2.2.0
FPC 3.2.2

pcurtis

  • Hero Member
  • *****
  • Posts: 951
Re: Custom form
« Reply #28 on: December 18, 2021, 08:42:43 pm »
@jamie after restart the files are created but i go back to the strange lpi error.

i wonder if this has ever been tested? many people on this forum have issues with templates
Windows 10 20H2
Laz 2.2.0
FPC 3.2.2

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4673
  • I like bugs.
Re: Custom form
« Reply #29 on: December 18, 2021, 10:41:18 pm »
after restart the files are created but i go back to the strange lpi error.
Are you now testing with the latest development version?

[Edit]  In 7e1fcc4033 I gave variables default values. Please test.
« Last Edit: December 18, 2021, 11:53:40 pm by JuhaManninen »
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

 

TinyPortal © 2005-2018