Forum > Lazarus Extra Components

package projtemplates: Variable ProjName and ProjDir in project.ini are useless


I'd like to preset ProjName and ProjDir in my project.ini file:


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


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 ...]
--- End quote ---

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.

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.


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 :-\


[0] Message Index

Go to full version