Download Lazarus The Complete Guide Free Pascal

1 view
Skip to first unread message

Giraldo Allain

unread,
Aug 20, 2024, 12:09:52 AM8/20/24
to selmooselni

Lazarus is a free and open source development tool for the Free Pascal compiler, which is also free and open source. The Lazarus Integrated Development Environment (IDE, see Screenshots) is a programming environment to create standalone graphical and console applications.

Download Lazarus The Complete Guide Free Pascal


Download https://psfmi.com/2A3fyq



Lazarus currently runs on FreeBSD, Linux, macOS and Windows and provides a customizable source editor and visual form creation environment along with a package manager, debugger and complete GUI integration with the Free Pascal compiler.

Several windows will appear on the desktop: the Main Menu at the top, the 'Object Inspector' on the left, the 'Source Editor' occupying most of the desktop, and a ready-made 'Form1' window (form1) overlying the Source Editor.

To place a button on the form: on the top Menu window, underneath the menu line, is a row of tabs. If the Standard tab is not already selected, select it by clicking with the mouse. Then find the Button icon (a rectangle with 'OK' on it) and click on that with the mouse. Then click on the Form1 window, somewhere to the left of the middle. A shadowed rectangle labelled 'Button1' will appear. Click again on the Button icon in the Standard tab, and click on the Form1 somewhere to the right of centre: a second rectangle labelled 'Button2' will appear.

Now edit the properties of Button2: click on Button2 to display its properties in the Object Inspector. Change its Caption property to 'Exit' instead of 'Button2'. Now select the Events tab, and click on the box for OnClick. Click on the ... ellipsis, and you will be taken into the Source Editor, in the middle of another procedure for button2:

Now Press F12 to see the Form1 window again. You should save your work now (and frequently!!) by selecting from the Main Menu Project-Save Project As > your_selected_file_name.pas. Next, you will be asked to save a Lazarus Project Information file, with the suffix .lpi. (Note: For Lazarus-0.9.30 you will be asked for project name first and then file name). Choose a different name for this file, if both are identical you will get a "duplicate identifier" compile error (see chapter "The Lazarus files" at the end of this tutorial).

You are now ready to try to compile. The simplest way to compile is to select 'Run' from the main menu at the top, and then the 'Run' option on the sub-menu. Alternatively you could simply press F9. This will first compile and then (if all is well) link and execute your program.

Several text windows will appear and all sorts of compiler messages will be typed, but eventually your Form1 window will re-appear, but without the grid of dots; this is the actual main window of your application, and it is waiting for you to push buttons or otherwise interact with it.

Re-open your saved Project and on the Form1 window click on the 'Press' button (Button1) to select it. Select the 'Events' tab on the Object Inspector, click on the right side box next to OnClick, click on the ... ellipsis, to go back to the appropriate point in the Source Editor.

If you prefer to write Console- or text-based Pascal programs (for example if you are following a basic Pascal programming course, or you need to write programs to use in batch mode or for system programming), you can still use Lazarus to edit, compile and run your programs. See Console Mode Pascal.

The first, running right along the top of the desk-top, is titled project1 - Lazarus IDE vXXXXXX (which will subsequently be modified to reflect the name of your currently-open project). This is the main controlling window for your project, and contains the Main Menu and the Component Palette.

On the line below the title bar is the Main Menu with the usual entries for File, Edit, Search, View categories and so on, with a few selections that are specific to Lazarus.Below this on the left is a set of symbols (icons which take you rapidly to particular menu commands); and on the right is the Component Palette.

Under the Lazarus Editor window will appear the 'Object Inspector' window on the left, and the Lazarus 'Source Editor' on the right. There may be another smaller window, labelled 'Form1', overlying the Lazarus Source Editor window. If this is not visible immediately, it can be made to appear by pressing the F12 key, which toggles between the Source Editor view and the Form view. The Form window is the one on which you will construct the graphical interface for your application, while the Source Editor is the window which displays the Pascal code associated with the application which you are developing. The operation of the Object Inspector is discussed in more detail below while the Component Palette is described. Finally, there may also be a Message window in the lower of the screen: this one is used by Lazarus to show feedback to the programmer, for instance when compiling a program.

When you start a new project (or when you first launch Lazarus) a default Form will be constructed, which consists of a box in which there is a grid of dots to help you to position the various components of the form, and a bar along the top which contains the usual Minimise, Maximise and Close buttons. If you click with your mouse cursor anywhere in this box, you will see the properties of this form displayed in the Object Inspector on the left side of the desk-top.

Other windows that may become visible during your work: the 'Project Inspector', which contains details of the files included in your project, and allows you to add files to or delete files from your project; the Messages window, which displays compiler messages, errors or progress reports on your project; if Lazarus was launched from a terminal window, the original terminal remains visible and detailed compiler messages are also printed there.

The small toolbar area, referred to as a Coolbar in the IDE options, to the left of the Component Palette, contains a set of buttons in two lines which replicate these frequently used Main Menu entries:

The image above also shows an added button (the same as the Run button image but with a red X) which compiles and runs without using the debugger. You can add and remove buttons by right-clicking on the toolbar and choosing Options. See IDE Coolbar for more details.

Each tab causes the display of a different set of icons, representing a functional group of components. The left-most icon in each tabbed group is an obliquely leftward-facing arrow, called the Selection Tool.

If you allow the mouse cursor to hover over any of the icons on the Component Palette, without clicking on the icon, the title of that component will pop-up. Note that each title begins with a 'T' - this signifies 'Type' or more accurately 'Class' of the component. When you select a component for inclusion in a form, the Class is added to the type section of the interface part of the Unit (usually as part of the overall TForm1), and an instance of that class is added to the var section (usually as the variable Form1). Any Methods that you design to be used by the Form or its Components (ie Procedures or Functions) will be placed in the implementation part of the Unit.

To use the palette, there must be an open form on view in the editor (if there isn't one, select File -> New Form). Click on the icon in the appropriate tab of the palette for the component you want to use, then click on the form, near where you want the component to appear. When the desired component appears, you can select it by clicking with the mouse. Once selected on the form, the object is also selected in the Object Inspector window, where you can edit its properties and events.

Adjustments to the visual appearance of an object can be made either by altering the picture itself on the Form using the mouse, or by changing the relevant Property in the Object Editor for that component.

If you install additional components, either those you have written yourself, or some coming as a package from some other source, then extra tabs with the relevant icons will appear in your Component Palette. These new components can be selected and used on your forms in the same way as those supplied by default.

In the following list of the Components, you will find links to files that contain descriptions of the Units in which they are found. If you want to find out about the properties of a particular component, it is often worth looking at the Inheritance of that component and then inspecting the properties of the base type from which it is derived. For example, to understand TMaskEdit it is also useful to examine TCustomMaskEdit.

For several good examples of the use of Components see the $LazarusPath/lazarus/examples subdirectory of your source installation. Many of the programs show how to use dialogs and other components directly without using the IDE and component palette or having a separate form definition file: all the components are fully and explicitly defined in the main Pascal program. Other example programs make full use of the IDE.

Some examples don't work straight away: you may need to play about with paths and permissions of files or directories. If you want to compile any of the examples, make sure that you have read/write/execute permissions for the files and directories, or copy the files to a directory where you do have the appropriate permissions.

The Units StdCtrls, ComCtrls and ExtCtrls contain definitions and descriptions of many of the most commonly used controls for constructing Forms and other Objects in Lazarus Applications.

If you drop a component on the form editor you don't need to add code explicitly to create it. The component is automatically created by the IDE together with the form, and destroyed when the form is destroyed. However, if you create the component yourself by code don't forget to free it when it is no longer needed.

For example, if you place a button (TButton) on the form, click on it to select it, then move it around the form with the mouse, you can watch the values of Top and Left change in the Object Inspector to reflect the new position. If you use the object's re-sizing bars to adjust its size, you can watch the Height and Width properties change as well.

b37509886e
Reply all
Reply to author
Forward
0 new messages