Recent

Author Topic: package projtemplates: Variable ProjName and ProjDir in project.ini are useless  (Read 2344 times)

RolfW

  • New Member
  • *
  • Posts: 21
I'd like to preset ProjName and ProjDir in my project.ini file:

[Variables]
ProjName=project1
ProjDir=my_test_folder

I expected to see the ProjectVariablesForm with EProjectName.Text and DEDestDir.Text prefilled with "project1" and "my_test_folder". But both variables are deleted from the variables list in IDETemplateProject.pp TTemplateProjectDescriptor.ShowOptionsDialog before showing the dialog. Is this intended or an error? Shall I open a bug report (and add a small patch)?

I'm using Lazarus 2.0.10

Thanks,
Rolf

lucamar

  • Hero Member
  • *****
  • Posts: 4219
I'm not sure but I think it's intentional. After all, the README says:

Quote
By default, the engine knows 2 variables:
ProjDir  : The directory where the new project will be created.
ProjName : The name of the project.

Additional variables must be defined in a file called 'project.ini' in the directory of the project. This is a file in Windows INI format.

[... etc ...]

Thinking about it, it's quite logical: otherwise you would be recreating the same project in the same place all the time, destroying the previous one, if you accepted that default.

Granted, for small test projects it might be the desired behaviour but that would be taking a narrow view of what templates can do.
« Last Edit: November 19, 2020, 11:30:08 pm by lucamar »
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

RolfW

  • New Member
  • *
  • Posts: 21
Hi lucamar,
frankly anwsering: no.
The code works like this:
Assign the variables list to an internal variable list. Delete ProjName and ProjDir from that list. Show the dialog (the TEdit boxes for name and dir are empty). Add the text of both as variables ProjName and ProjDir to the variables list when the dialog is closed.
So, what's missing is simpy to prefill the TEdit boxes with ProjName and ProjDir. Can be changed in the dialog.

Rolf

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Yes, I got that from your first post; that's why I think it's intentional: the coder took the trouble of deleting them before showing the dialog, and I just offered a possibe reason, which might or might not be the correct one :-\
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

 

TinyPortal © 2005-2018