Using a Lazarus Project Information (.lpi) File

When you save a project, Lazarus stores all details of the project in the .lpi file by default. You can open it with a text editor to see the values stored. This file has XML format and stores information such as:
  • the name of the project;
  • the required packages (often just LCL, which is automatically included in a forms application);
  • the units and associated forms;
  • the details of these files when you viewed them last;
  • the "jump history" (lines you have navigated to by CTRL-clicking in the source code).

In the previous page we showed you how to add files to a project. If you have the .lpi file of a project in your program folder, the necessary files are already part of the project from the outset. For example, using the same example as on the previous page, within the ProjectOptions tag of our MenuDemo.lpi project information file is the following units tag.

<Units Count="9">
  <Unit0>
    <Filename Value="MenuDemo.lpr"/>
    <IsPartOfProject Value="True"/>
  </Unit0>
  <Unit1>
    <Filename Value="uRed.pas"/>
    <IsPartOfProject Value="True"/>
    <HasResources Value="True"/>
    <UnitName Value="uRed"/>
  </Unit1>
  <Unit2>
    <Filename Value="uBlue.lfm"/>
    <IsPartOfProject Value="True"/>
  </Unit2>
  {Units 3 - 8 omitted}
</Units>            

We chose the project option to save our session information in the .lps file.

Compare this entry in the .lps file for Unit 1 with the above:

<Unit1>
<Filename Value="uRed.pas"/>
<IsPartOfProject Value="True"/>
<HasResources Value="True"/>
<UnitName Value="uRed"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="3"/>
<WindowIndex Value="0"/>
<TopLine Value="6"/>
<CursorPos X="16" Y="26"/>
<UsageCount Value="22"/>
<Loaded Value="True"/>
</Unit1> 

By saving our session info in the .lps file, we have prevented this data from being saved in the .lpi file. Similarly our jump history appears in the .lps file rather than the .lpi file. For some programs we will provide the .lpi file for your use. This is particularly helpful when we have added packages to the project. An alternative method for obtaining a suitable .lpi file for distribution is to publish the project. Publishing strips out the details that are unhelpful to an end user.

Carry out the following steps to save session information in the .lps file.

  1. Select the menu item Project > Project Options
  2. Select the Session page
  3. Select the option to save session information in the .lps file in the project directory

To publish the project, select the menu item Project > Publish Project ... then select or navigate to a suitable Destination Directory. If you want a compressed file of your project, select the appropriate "Command after" from the combo box. Click on the Ok button to publish.

Features introduced:
  • New application created using .lpi file

  • Examining an .lpi file

  • Saving session information in the .lps file

  • Publishing a project

Programming - a skill for life!

How to set up Lazarus to create, edit and run form-based Object-Pascal applications