Forum > Beginners

Problem creating a Template for a Form

(1/3) > >>

Dzandaa:
Hi everybody,

Using Lazarus version 2.0.12 FPC 3.2.0 on Windows

I create a template for a Form following the tutorial https://wiki.lazarus.freepascal.org/Project_Templates

Everything looks fine except in the .lpi where all instance of "Project" are replaced with "MyTest" (The name of my new program)

Example:


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---<ProjectOptions> -> <MyTestOptions> <SessionStorage Value="InProjectDir"/> ->       <SessionStorage Value="InMyTestDir"/>
If I change it "by hand" the project is working.

The files in: template\MyForm



project.ini
__MAINUNIT__.lfm
__MAINUNIT__.pas
__PROJNAME__.ico
__PROJNAME__.lpi
__PROJNAME__.lpr
__PROJNAME__.lps
__PROJNAME__.res


The resulting Files:


MyTest.ico
MyTest.lpi
MyTest.lpr
MyTest.lps
MyTest.res
MyTestU.lfm
MyTestU.pas



project.ini:


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} --- [Variables]  MAINUNIT=Filename for the default unit.pas file MAINFORM=Form name  [Project] Name=My Custom Form Author=Dzandaa Description=Lazarus LCL form specifically for my needs 

Any Idea?

Thank you.

jamie:
Trying to figure your problem and what I get is you created a Template with a currently active project that you have already did a SaveAs and gave it a new name?

  So, I assume you are talking about the template taking on the name of your current project that you renamed at some point different than Project.

  I guess if you are into making templates wouldn't it be prudent to simply use a default name of a project so the template can take on the same name?

 I mean, the template is only used to start a new app and move on from there, you can then rename that project to something meaningful which shouldn't affect the template from there on.

  I suppose there could be an option to ask for a name when saving the template, who knows.
 
  Why not submit to the laz bug site as a suggestion as a feature?

ASerge:
Maybe I misunderstood the question, but inside *.lpi in the template you need to enter __PROJNAME__ instead of the project name.
And this is documented in the "File content" section.

Dzandaa:
Hi again,

Thank you.

Here is my __PROJNAME__.lpi


--- Code: XML  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---<?xml version="1.0" encoding="UTF-8"?><CONFIG>  <ProjectOptions>    <Version Value="11"/>    <PathDelim Value="\"/>    <General>      <SessionStorage Value="InProjectDir"/>      <MainUnit Value="0"/>      <Title Value="__PROJNAME__"/>      <Scaled Value="True"/>      <ResourceType Value="res"/>      <UseXPManifest Value="True"/>      <XPManifest>        <DpiAware Value="True"/>      </XPManifest>      <Icon Value="0"/>    </General>    <BuildModes Count="3">      <Item1 Name="Default" Default="True"/>      <Item2 Name="Debug">        <CompilerOptions>          <Version Value="11"/>          <PathDelim Value="\"/>          <Target>            <Filename Value="__PROJNAME__"/>          </Target>          <SearchPaths>            <IncludeFiles Value="$(ProjOutDir)"/>            <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>          </SearchPaths>          <Parsing>            <SyntaxOptions>              <IncludeAssertionCode Value="True"/>            </SyntaxOptions>          </Parsing>          <CodeGeneration>            <Checks>              <IOChecks Value="True"/>              <RangeChecks Value="True"/>              <OverflowChecks Value="True"/>              <StackChecks Value="True"/>            </Checks>            <VerifyObjMethodCallValidity Value="True"/>          </CodeGeneration>          <Linking>            <Debugging>              <DebugInfoType Value="dsDwarf2Set"/>              <TrashVariables Value="True"/>              <UseExternalDbgSyms Value="True"/>            </Debugging>            <Options>              <Win32>                <GraphicApplication Value="True"/>              </Win32>            </Options>          </Linking>        </CompilerOptions>      </Item2>      <Item3 Name="Release">        <CompilerOptions>          <Version Value="11"/>          <PathDelim Value="\"/>          <Target>            <Filename Value="__PROJNAME__"/>          </Target>          <SearchPaths>            <IncludeFiles Value="$(ProjOutDir)"/>            <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>          </SearchPaths>          <CodeGeneration>            <SmartLinkUnit Value="True"/>            <Optimizations>              <OptimizationLevel Value="3"/>            </Optimizations>          </CodeGeneration>          <Linking>            <Debugging>              <GenerateDebugInfo Value="False"/>            </Debugging>            <LinkSmart Value="True"/>            <Options>              <Win32>                <GraphicApplication Value="True"/>              </Win32>            </Options>          </Linking>        </CompilerOptions>      </Item3>    </BuildModes>    <PublishOptions>      <Version Value="2"/>      <UseFileFilters Value="True"/>    </PublishOptions>    <RunParams>      <FormatVersion Value="2"/>      <Modes Count="0"/>    </RunParams>    <RequiredPackages Count="1">      <Item1>        <PackageName Value="LCL"/>      </Item1>    </RequiredPackages>    <Units Count="2">      <Unit0>        <Filename Value="__PROJNAME__.lpr"/>        <IsPartOfProject Value="True"/>      </Unit0>      <Unit1>        <Filename Value="__PROJNAME__u.pas"/>        <IsPartOfProject Value="True"/>        <ComponentName Value="__PROJNAME__"/>        <ResourceBaseClass Value="Form"/>      </Unit1>    </Units>  </ProjectOptions>  <CompilerOptions>    <Version Value="11"/>    <PathDelim Value="\"/>    <Target>      <Filename Value="__PROJNAME__"/>    </Target>    <SearchPaths>      <IncludeFiles Value="$(ProjOutDir)"/>      <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>    </SearchPaths>    <Linking>      <Options>        <Win32>          <GraphicApplication Value="True"/>        </Win32>      </Options>    </Linking>  </CompilerOptions>  <Debugging>    <Exceptions Count="3">      <Item1>        <Name Value="EAbort"/>      </Item1>      <Item2>        <Name Value="ECodetoolError"/>      </Item2>      <Item3>        <Name Value="EFOpenError"/>      </Item3>    </Exceptions>  </Debugging></CONFIG>  

Perhaps you'll find what is wrong :)

B->

Thaddy:
What is wrong is manually edit it: it is a generated file, don't touch it!
For other editors that file is not even necessary, just for Lazarus IDE. In general one would look for the lpr, not the lpi.
Maybe the lpi files should contain a warning about that.....
And it is NOT a template at all. It is configuration.

Navigation

[0] Message Index

[#] Next page

Go to full version