Project template
lazarus / 9-Editor
----------------------------------------------------------------------
pcurtis · 2020-08-26 11:33
Hi All,
I have created a project template (see attacment), and I can create a
new project based on this template.
The problem is that the Project inspector does not show one of
required files (laz_synapse).
When I try to run the program the IDE complains that the new project
lpi file has changed and asks if I want to reload it. If I say yes,
the file reloads, the project compiles and runs. Even the Project
inspector displays the correct requirements.
My question is this "Do I have to reload the lpi file?" It feels like
I am doing something wrong or is this yet another undocumented
feature?
Please help.
Thanks.
----------------------------------------------------------------------
paweld · 2020-08-26 13:27
replace files from the attachment in
$(LazarusDir)\comonents\projecttemplates and rebuild the IDE
----------------------------------------------------------------------
pcurtis · 2020-08-26 13:45
Thanks (I haven't tried it yet).
How do you classify this error / short sight... ? Does it need to
pointed out to anyone?
----------------------------------------------------------------------
paweld · 2020-08-26 13:51
I don't know if it's a bug, maybe it should be reloaded - that's why I
didn't report it.
However, it really bothered me so I made some changes
----------------------------------------------------------------------
pcurtis · 2020-08-26 13:56
How would I go about getting this fixed on a more permanent basis?
----------------------------------------------------------------------
pcurtis · 2020-08-26 14:04
OK, I just tried to install the changes and get the following error:
Compile package ProjTemplates 1.0: Exit code 1, Errors: 1
frmtemplatevariables.pas(12,21) Fatal: Cannot find ptstrconst used by
frmTemplateVariables of package ProjTemplates.
----------------------------------------------------------------------
paweld · 2020-08-26 14:11
I understand you only replaced these 2 files and the rest of the files
remained in the directory?
----------------------------------------------------------------------
pcurtis · 2020-08-26 14:19
Yes.
It can't find the unit ptstrconst
----------------------------------------------------------------------
pcurtis · 2020-08-26 14:28
I use Win 10 x64 if this helps
----------------------------------------------------------------------
paweld · 2020-08-26 14:30
try now
----------------------------------------------------------------------
pcurtis · 2020-08-26 14:46
The IDE compiles, but the orignal problem hasn't changed
----------------------------------------------------------------------
paweld · 2020-08-26 14:55
clear folder $(LazarusDir)\comonents\projecttemplates\lib and rebuild
the IDE again
----------------------------------------------------------------------
pcurtis · 2020-08-26 15:48
Even worse.
I can rebuild the IDE. Make a new project. Then the IDE locks up.
I get this error (see attachment)
----------------------------------------------------------------------
paweld · 2020-08-26 18:13
I am using the Lazrus trunk, and only recently noticed that you are
using 2.0.10.
In the attachment, the corrected version of the component from this
version of Lazarus.
----------------------------------------------------------------------
pcurtis · 2020-08-26 18:57
Still the same error.
I deleted all files in c:\lazarus\components\projecttemplates\ (except
the languages directory). Copied your files, rebuilt the IDE, created
a new project from my template and it crashed.
----------------------------------------------------------------------
paweld · 2020-08-27 05:27
if you use additional variables in the template, you must define the
value of these variables before creating the project from the template
sample template in attachement
----------------------------------------------------------------------
BeanzMaster · 2020-08-27 08:35
Hi, @Paweld is on the way !
One you have created your from.
1) Save the project with the name, "mytemplate" (for example) in a new
subfolder of the same name under the .lazarus / templates folder.
Leave the default name Unit1 for the main form.
2) In the project template folder, create a text file called
project.ini (this name is required). This file contains the
information Lazarus needs to create a project based on the template.
Here is its content
Code: Pascal [Select][+][-]window.onload = function(){var x1 =
document.getElementById("main_content_section"); if (x1) { var x =
document.getElementsByClassName("geshi");for (var i = 0; i
[Variables]MAINUNIT=New filename for the Unit1.pas fileMAINFORM=Main
form nameMAINMENU=Main menu name[Project]Name=My Wonderful Custom
applicationAuthor=ItsMeDescription= MyNew form
3) Now comes a slightly tedious step: implementing the variables in
all the files that make up the project. It is possible to automate
this process using a small batch or shell application,
QuoteIMPORTANT
all variable names must be preceded and followed by a double
underscore character.
So, if a MAVARIABLE variable has been defined in the project.ini file,
it must be implemented as __MAVARIABLE__ in file names or in file
contents.
The same goes for types: the type of the variable MAVARIABLE must be
implemented in the form T__MAVARIABLE__.
First, rename the Unit1.pas and Unit1.lfm files to __MAINUNIT __. Pas
and __MAINUNIT __. Lfm.
Then rename all the project files (lpi, lpr, res) to __PROJNAME __. *.
The PROJNAME variable is a variable defined by default which
represents the name of the new project when it is saved.
Do not touch the secondary files, if you have more than one 'form',
they will keep these names in the new project.
4) It is now a question of opening each file making up the project and
implementing the model variables there.
The __MAINUNIT __.pas file:
All occurrences of Form1 must be replaced by __MAINFORM__;
All occurrences of TForm1 must be replaced by T__MAINFORM__;
MainMenu1 must be replaced by __MAINMENU__.
The __MAINUNIT __. Lfm file:
All occurrences of Form1 must be replaced by __MAINFORM__;
TForm1 must be replaced by T__MAINFORM__;
All occurrences of MainMenu1 must be replaced by __MAINMENU__.
The __PROJNAME __. Lpr file:
The program identifier must be replaced by __PROJNAME__;
In the uses clause, Unit1 must be replaced by __MAINUNIT__;
Form1 must be replaced by __MAINFORM__;
TForm1 must be replaced by T__MAINFORM__.
The __PROJNAME __. Lpi file:
All instances of debugtemplate must be replaced by __PROJNAME__;
Except for the and tags, all occurrences of Unit1
must be replaced by __MAINUNIT__;
Form1 should be replaced by __MAINFORM__.
The __PROJNAME __. Lps file:
Prjoecttemplatename must be replaced by __PROJNAME__;
Except for the and tags, all occurrences of Unit1
must be replaced by __MAINUNIT__;
Form1 should be replaced by __MAINFORM__.
5) The project model being finalized, it is time to test its use.
Create a new project, the new model now appears in the list.
You can see how the contents of the Name and Description keys of the
project.ini file are used by Lazarus.
Select the new model then click on 'OK'. Lazarus asks you for the
value of the different variables you have implemented
Once all the fields are completed, click “OK”. Now you have your new
project
That's all folks
You can read the original tutorial in french from Alcatiz here :
https://alcatiz.developpez.com/tutoriel/lazarus-modele-projet/
Best regards
----------------------------------------------------------------------
pcurtis · 2020-08-27 14:02
Thats fine but it still does not solve the opening issue.
I have attached my template so you can check.
----------------------------------------------------------------------
paweld · 2020-08-27 14:31
no problem with create a new project from attached template
edit: i found problem, when in a destination dir exists another
project(s) and one of these projects is open then IDE show error: File
not found 'new project.lpi'
----------------------------------------------------------------------
pcurtis · 2020-08-27 15:29
Hi, and the project inspector shows "laz_synapse" and doesn't complain
about lpi changes when you try to run?
----------------------------------------------------------------------
paweld · 2020-08-27 15:43
yes: https://drive.google.com/file/d/13p5VKxaR3zwuK-
1dTxq8xrpheA5l8VaK/view?usp=sharing
----------------------------------------------------------------------
pcurtis · 2020-08-27 18:31
OK, I believe you.
Before I throw my PC out the window, could you post your template so I
can try it?
Also did you use the patches that you posted? If so what files
exactly.
Thanks for your support.
----------------------------------------------------------------------
paweld · 2020-08-28 08:25
Hi,
i replace only idetemplateproject.pp on
$(LazarusDir)\components\projecttemplate.
or download entire lazarus: https://drive.google.com/file/d/1dAcftpJoR
6ocJiel8oZL2i_r4D5XKHsF/view?usp=sharing
----------------------------------------------------------------------
pcurtis · 2020-08-28 09:17
Thank you very much I'll download and look later. Atleast my weekend
won't be boring.
I'll post the results.
Thanks.
----------------------------------------------------------------------
pcurtis · 2020-08-28 11:17
OK, I feel like a complete idiot
Could I ask for a step by step guide. I have removed lazarus + all
config data from my PC.
Reinstalled from lazarus-2.0.10-fpc-3.2.0-win64.exe using defaults.
Deleted all files from c:\lazarus\components\projecttemplates\lib\
Copied idetemplateproject.pp from idetemplateproject.zip to
c:\lazarus\components\projecttemplates\ and overwrote the existing
file.
Started Lazarus and added synapse (Package -> Open package file ..
then compiled it, closed Lazarus and reopened to check that
laz_synapse is available for use)
Rebuilt lazarus (Tools -> Build Lazarus with norma IDE profile)
Created a new directory c:\Templates and copied the two templates from
templates.7z
Set the Project Template Option to C:\Templates\
Selected Project -> New Project -> Test Project
Set name for new project = hhhh
Set directory c:\work\test
Set MAINUNIT = bbbb
Set TITLE = nnnn
Set BTNCAPTION = mmmm
Pressed OK.
When I compiled it complained that hhhh.lpi has changed
I have to reopen to get everything how it should be.
How can I use your test lazarus? There is no lazarus.exe.
What next?
----------------------------------------------------------------------
paweld · 2020-08-28 11:41
- replace file idetemplateproject.pp on directory
$(LazarusDir)\components\projecttemplate
- Lazarus IDE > Menu: Tools > Build Lazarus
- install Synapse (Packages > Online Package Manager)
- copy template project to directory from Tools > Project templates
options ...
----------------------------------------------------------------------
pcurtis · 2020-08-28 13:05
I did all that as explained in my previous post
----------------------------------------------------------------------
paweld · 2020-08-28 13:16
actually.
rename lazarus.old.exe to lazarus.exe and rebuild IDE, or you can
download lazarus.exe from here: https://drive.google.com/file/d/1N9438
kl1KQuo89ybgp-g0ASGIbfBFgiI/view?usp=sharing
----------------------------------------------------------------------
pcurtis · 2020-08-30 05:04
OK. I give up, I am tired of uninstalling / reinstalling. I will have
to live with how it is.
Thanks anyway.