Lazarus scatters itself across the screen in 5 basic windows.
Each one can be moved around and re-sized in the usual way, to suit yourself:
is the main command window. Closing this closes Lazarus. Minimizing this minimizes everything.
is the window representing the part of the program which you are working on. This is where you drag and drop the buttons and boxes which make up your program. The dots are a grid to which they can be aligned for a neater result. The dots don't show when the program runs. Program windows are called Forms
. The data for a form is saved in a .lfm
is the Editor
window. This where you write the code which makes things happen when the buttons and boxes are clicked. Each form has its own corresponding chunk of code, called a Unit
. Each unit is saved in a separate .pas
file with the same name as the corresponding form file.
Each unit appears in a separate tab in the editor window. The current tab being edited is highlighted. An asterisk against the file name in the tab indicates that the contents have been changed and will need saving.
The editor and form windows can be toggled to and fro in front of each other by pressing F12
on the keyboard -- which is handy if you are working with large forms on a small screen.
The font used in the editor needs to be a fixed-width font if you value your sanity, so that the text appears in fixed columns. By default the font used is Courier New, but I find the Consolas font is easier on my eyes.
The editor changes the colours of the text according to its meaning to the compiler. This is called "syntax highlighting". This is very useful to avoid typing errors. The colours and formatting can be changed to whatever you find comfortable.
Chunks of text can be hidden from view by clicking the small + and - boxes on the left. This is called "folding" the text. It is very useful to reduce scrolling when working on a long unit.
is called the Object Inspector
window. This is where you make the settings for each Object
in the program by entering them in the right-hand column. For example if you add a button to a form, this is where you set the text which appears on the button. Almost everything in Lazarus is an object, so this Object Inspector window is used a lot. It is typically arranged as a tall column window. Most programmers seem to like it on the left of the screen, but I prefer it on the right.
is the Messages
window. This is where Lazarus reports what's happening -- hopefully on a green background to indicate a successful operation. You can close this window when not needed and it will re-appear when there is something to report.
Other smaller dialog windows appear in the usual way as needed.
In the screenshot above I am editing the control_room
unit. Users who were in at the first release of Templot in 1999 will recognise these names. This window is now called the program panel
, but it was then called the "control room". I changed it on the visible window to avoid confusion with the control template, but the original names in the code haven't changed.
Likewise the storage box
is in the keep_select
unit. Stored templates were then called "keeps". I was persuaded to change the name by Brian Lewis (then of C&L), but I often regret it. You will find the term "keep" for a stored template is still used throughout the code.
The Object Inspector above is currently showing the settings for the recent files
button object. You can see that I have clicked on it, and it has gained some corner handles which could be used to drag it around and resize it.
The form is shown at design-time with all objects visible. When the program is run they are not necessarily all visible at the same time. On this window the blue bar behind the buttons is not visible at the same time as the row of buttons.
Lazarus makes some default settings when an object is created. Most of them can be left on the defaults, but you will always need to change a few of them. As you can see I have made some settings:
Every object in Lazarus must have a name
, so that it can be referred to in the code. For this button you can see that I have given it the name recent_button
. Spaces are not allowed in names. It could be called anything (beans_on_toast ?) but it is handy to use a sensible name and include a reference to the type of object. Otherwise when you come to read the code again in a few years time (or in my case 5 minutes later) it will be meaningless.
Lazarus is case-insensitive, so recent_button, RECENT_BUTTON, Recent_Button, reCenT_buTton, all mean exactly the same thing and refer to the same object. Lazarus itself uses camel-case, so that objects and functions have names such as ToggleBox or SaveToFile.
You can do the same if you wish for names, but I prefer to use all lower case separated by underscores: toggle_box, save_to_file. This has the useful advantage when reading code that I can see immediately which names were created by me, and which were created by Lazarus.
Next we need to set the text which appears on the button. This text is called an object's Caption
. Generally the text which appears on the screen on a button, next to tickbox, etc., is called its caption. As you can see I have set this to "&recent files". I often use a double space for easier reading. The &ersand causes the next letter to appear underlined on the button as a keyboard accelerator key.
You can see some of the other settings, all of which can be changed. The Height
of the button is set to 29 pixels. Left
means the left edge of the button is 91 pixels from the left edge of the form.
message ref: 24923