Suggestion: Your browser has a "Find in this page" tool... probably worth using, if you are looking for something specific.
Do you want to know how to do specific things using the free Lazarus programming environment for Linux and Windows?
Not installed your Lazarus yet? Using Windows? then please check this note if you have a 64-bit machine ! ! ! !
Start Here This takes a complete beginner through a first project.
Gently Does It Further adventures
File transcription How to make a massaged copy of a file
Those are just a few of the essays on offer. A little further down the page is a comprehensive table of available essays. In "Level Zero" you'll find a little help with installing Lazarus. Remember: it is free, and that it runs on Linux, Windows and Macs.
Who says this is the place for Lazarus help? Me, the site's editor! I may be new to actually using Lazarus. But I have been using computers since 1968, and using Delphi, which informed Lazarus, for many years. I have been writing tutorials for Delphi and Open Office's database, and the Arduino microprocessor for many years. Anyway... a (Lazarus) newbie (me) won't assume that you (fellow newbie?) know all those things that the "experts" take for granted!
If you want things that are not here... yet... try using any of my Delphi tutorials with Lazarus, and, please, let me know how you get on. Works? Not? Please tell me which Delphi tutorial you tried. If you have problems when using one of the Delphi tutorials, I will try to resolve them for you. The ones I've tried have worked fine with Lazarus.
And of course other people's Delphi (and Pascal) pages will probably give you answers to Lazarus questions. I particularly like the Delphi reference at www.delphibasics.co.uk/.
My pages are browser friendly. Make your browser window as wide as you want it. The text will flow nicely. It is easier to read in a narrow window... and the rest of your screen will be free for your ooBase exercises! Hold down the control key ("ctrl") and press the plus sign, the minus sign, or zero to change the size of the text in Firefox and other good browsers. This and other hints explained on my Power Browsing page!
There are more notes at the bottom of the page about other offerings, my editorial philosophy, a button to email me, and a search engine to help you find things on my site.
If you are not only new to Lazarus, but also new to programming, or programming with Pascal, you might want to study Pascal a little first. The compiler "underneath" Lazarus can be used more directly. What you learn that way will contribute to your mastery of Lazarus... but you don't need to start there, unless you wish to. You can just leap straight into Lazarus, and learn the Pascal along the way. At my Pascal course there are lessons written for the "FPC" environment ("Free Pascal Compiler"). "FPC" refers to the compiler Lazarus uses. To get the FPC, I suggest that you install Lazarus, even if you don't want to use all of it yet. The FPC will be installed along with the rest of Lazarus, and your installing will be done once and for all. But you can use other routes, if you would rather hold off doing "everything" for now.
I installed Lazarus on my Windows XP machine without any drama. (First install: 26 July 2011, vers 0.9.30 for 32-bit Windows.)
In the past, I have sometimes had trouble connecting to the Lazarus homepage. This is a quirk of my system. It has happened before with a few specific sites. The last time (July 2011) it was playing up, lots of my friends were connecting without problem.
The installation process is pretty unremarkable. If you have a 64 bit Windows machine, you may still want to install the 32 bit version, so that the things you write can be used on either 32 bit machines, or their bigger brothers.
If you'd like help, visit the official guides first, but if you want more help, you are welcome to what's in my brief "Installing Lazarus" note.
Start Here This takes a complete beginner through a first project, covers points that apply to any project, and covers some points about conventions used in my other tutorials. "Start here" is long and perhaps tedious, but I really do recommend it to you strongly.
Level 1 Tutorials:
Gently Does It Once you have mastered the basic skills in my Start Here tutorial (in Level 0, above), you will be ready for this tutorial in which you are taken gently by the hand, and given lots of help. I'll tell you what the application at the heart of the tutorial does in a moment... but first I would like to explain something.
The content of "Gently Does It" was designed to familiarize you with some fundamental concepts of event driven programming. We are, of course, working in Lazarus in these tutorials, but the concepts covered in "Gently Does It" will help you with any Linux or Windows or Mac programming.
Yes, but what does it do?? Oh well, all right: It creates an application to ask users ""What is 5+9?", "What is 7+2?", etc. But that's not the point!
Constants and Comments... and version ID Short and sweet... but do take a moment to visit the "tutorial"... more of a little "How To", really. Comments (also known as "rems", or remarks) help you stay in charge of the code in an application. Constants are useful alternatives to variables in some circumstances, and I will suggest using a particular constant in every application, to indicate the application's version. And I will show you how to get that version information displayed in the application's title bar.
The parts of a Lazarus unit Once you have done the Gently Does It tutorial, above, if you are feeling determined and brave, this long and tedious essay about all of the parts of the code for a simple Lazarus (or Delphi) application will repay your efforts. It had better, anyway, for you won't be reading it for fun!
Edit box OnChange Event At last! Something fun! (Well... more fun than the getting started tutorials have been. In this one you should "learn by doing".) You will be shown how to create a little application with two edit boxes. Whatever you type into one will appear in the other... with changes.
Not, perhaps, an application to fund my retirement, but if you work through creating it, it should extend your familiarity with the tremendously powerful "thing" called an event, and the handling thereof. (Equally useful to Lazarus and Delphi programmers)
Data Types For the moment, this link merely takes you to other people's work at http://wiki.freepascal.org/Variables_and_Data_Types. And there you will find "everything", which is rather more than a novice needs. I will try to produce a tutorial in due course, but many, many hours are wasted in connection with problems over data types. (It was, in fact, the basis of the Y2K "bug"... which was a serious threat to Life As We Knew It, but because the programmers overcame the danger, too many people think it was a case of "Wolf! Wolf!". (I do have a tutorial on data types for Delphi, but while almost everything Lazarus matches Things Delphi, this is just the sort of place that a tiny difference could be a Big Pain. Another thing: If you are working with Dallas 1-Wire devices, beware the data type terms they use. They use the same terms but to mean different things than Delphi/ Lazarus people use them for.
A "little point" on Lazarus data types. At the page cited, we are told that type "integer" will store either a smallint (-32768 .. 32767, 2 bytes, pp the same page) or a longint (-2147483648 .. 2147483647, 4 bytes, ditto). Two things arise: If you don't need the negative numbers, I'd be inclined to Go For Simple... and use "word" (0-65,535 in 2 bytes) (or "byte", 0-255 in 1 byte) However, maybe I am being foolish. That "ambiguity" in the "integer" type may derive from it being the "basic" type, and whether it consists of 2 or 4 bytes is determined by whether you are using a 32-bit or 64-bit machine/ OS. Novices: Don't worry... in most cases this won't matter!
Drawing Introduction to graphics. All you need is a "surface" to draw on, and then it is easy. You can "paint" a pixel, or do lines (moveto/lineto).
Moveto, Lineto STOP PRESS Concerning graphics programming. Please visit this page BEFORE reading any of my other graphics programming tutorials. Important corrections to some details.
Level 2 Tutorials:
Zip archive with Celsius to Fahrenheit Converter sourcecode Celsius to Fahrenheit Converter... and it converts both ways! The tutorial for this isn't finished yet, but you can download a zip archive with a compiled .exe file, and some code which works, even if maybe it needs some tidying! This application is an extension of the one covered in the Level 1 tutorial Edit box OnChange Event.
Using .ini files: Good for configuring applications, making them remember their previous state, etc. (I've written about this topic many times, in many places... sometimes badly! This, I believe, is finally pretty good- 9/13).
Re-using a Lazarus project: A short tutorial explaining the simple process of building a new Lazarus project from an earlier, similar, one. Not difficult. Only placed in Level 2 because this isn't something beginners need to struggle with.
File transcription Don't be alarmed if when you use this link, and find yourself in Delphi- land!
If only life were always so easy! I wrote a tutorial for Delphi. I tried using that with Lazarus, and, Oh Joy, discovered that nothing in it had to be done differently for Lazarus. The tutorial uses the OpenDialog, SaveDialog and Memo components to copy the contents of an existing file to a new file. To give the exercise some "point", the contents of the file are slightly modified. This is enough to show you the essentials for many tasks. The application in the tutorial is a shell you can adapt for your needs.
You may think it is lazy of me to offer one tutorial to two audiences. Not at all. I'm being careful. If I wrote two tutorials, and subsequently users told me of bits that could be more clear, I would need to update both tutorials, keep them in step. By using one tutorial, and introducing special notes as necessary, there is no danger of one audience becoming a "second class" audience. With only one tutorial, there isn't a second one which could miss an update, become inferior.
STRUCTURE, Planning, Testing: A structure for building a "do these things, one after the other" loop. Typically at the heart of a program's operation.
STRUCTURE, Planning, Testing: Postscipt to the previous tutorial, a frill for that structure for building a "do these things, one after the other" loop.
Level 3 Tutorials:
Looking for folders and files: Traversing the folders of your hard disk (or other backing store). Seeing what files are present. ("Folders" is another word for what is called a "directory" in some contexts.) Using FindFirst and FindNext. A major tutorial, reasonably complete. (If about a somewhat esoteric topic!)
Design and Development: How do programmers do it? How do they go from a broad idea to a finished application? In this tutorial, I will try to shed some light on the process.
It is an unusual tutorial... it is more "complete" and polished than some. But it also barely touches on the part of the process which most of these tutorials are about: the code that makes the application do what it does. It talks about how programmers get ready to start writing the code. (Writing code should not be the first step of creating an application! How much do you know about what precedes that?)
I commend it to you, if you have a little time to step back from your current project, and try to learn some skills which may help you create applications more easily. Or create better applications. Or maybe you will get both benefits!
Getting your application to automatically copy text to the system clipboard or paste things into your application from the clipboard: An unusually brief tutorial... but "it does what it says on the tin", and the techniques are useful. This is in level 3 only because those techniques aren't broadly important, and also the tutorial has been written for readers who are not new to Lazarus.
Moving .jpgs around your hard drive, building a page of HTML to display some of them: Comes complete with full source code and a pre-compiled .exe file. This is a much bigger tutorial than many. I have taken a lot of time to write up for you an example of how to go from an idea to a working application. The subject of this tutorial is an application which makes copies of selected still images from known locations on your hard drive, and then assembles a page of HTML to use for looking at the copies the application has collected. Lots of useful Good Practice illustrated along the way. Not a "quick answer" to any "how do I...?" questions... but I think that serious students of programming will be rewarded by time spent with the tutorial. I hope so, anyway, given the time I've spent on writing it! Many of the specific techniques mentioned, e.g. moving a .jpg, have wider applicability. You can, for instance, move other files the same way as you move a .jpg.
Checksums and Ini files and More: An unusual tutorial... but gives you access to the sourcecode of a larger application that is typically the topic of a tutorial. (I also offer another... probably better... tutorial just about .ini files. (The better ini file tutorial has an entry of its own further up the page under Level 2)).
I actually needed an application that I could also present to you for whatever programming information you can glean. From it, you should be able to see how to use an ini file to save your window's size and position between runs, there's a crude implementation of printing text. Lots more! The application does calculate a checksum for a string of characters. The mathematics involved may broaden you knowledge, but is unlikely to be a quick answer to your question of the moment!
Loops, Boolean flags, text manipulation: Not a lot of "tutorial" with this one, yet, but some free sourcecode to "play" with. It loads a text file... it would make most sense if the text file consisted of simple html with some <pre> blocks in it... and makes changes to just stuff in the <pre> blocks. That, I understand (!) may not be of interest to a huge audience... but I think that the application illustrates some important general techniques along the way.
The globe on the right helps me see if doing these pages is worth the time it takes. It is interactive; play with it, if you wish. (You need to use your browser's "back" button to get back here after doing so.) The only information the system records is when visitors access the site, and where their ISP connected them to the internet. (In my case, that is 60 miles from where I live, at the moment.)
This comes to me as a free service from Revolvermaps.com. If you know how to insert HTML into your own web pages, it is easily added.
Level 4 Tutorials:
Simple yet complex graphics and use of arrays: In this, you are provided with the sourcecode to create an animated graphic, showing "things" moving. (Or you can just download the compiled .exe, to see it in action with minimal fuss.) It could be the basis of many things. Along the way, you can see arrays used, if I say so myself, cleverly and elegantly. The program was written with flexibility in mind, can be adapted to many purposes. I wrote it because I wanted to simulate what you would see through a microscope, looing at a population of mobile one celled animals. It could also be used to simulate schooling fish, migrating wildebeest, particles in a gas... what will you do with it?!
Drawing graphs, Using pmXOR, Using multiple ini files: This is a huge tutorial, covering a lot of ground. Written over a period of weeks in May 2014, when I'd been doing these tutorials for a long time. Not a quick answer to "How do I...", but a rather different tutorial, due to the scope of the task accomplished: the creation of an application to draw graphs from multiple data files, with user-positioned lines on each, and the positioning of the lines remembered from session to session. Complete sourcecode provided. Ideas covered should also work with Delphi. This tutorial written after I'd become aware of the "error-of-one" that is easy to make with "lineto", which is explained in my short tutorial on that subject.
Miscellaneous Matters- including Macintosh:
I shoould start with a quick advert and disclaimer.
Yes! Lazarus "works" on a Mac!
Sadly, as a reluctant slave of Redmond, I am "used" to doing things the Windows way, and found my first experiences of the Mac environment... trying. However, eventaually, I had Lazarus up and running... and it WORKED! It was much like using Lazarus under Windows. Oh joy!
But... having worked long and hard to get my development environment set up, and in just a few moments written a little "Hello World", I REALLY did not need the "joy" of discovering that to send my creation to a potential customer was also, compared to doing it with Windows, a long struggle. But I got there... I think. Which is what the following is all about!!....
I need your help! This page gives you a chance... lucky you... to download an "Hello world" program which I created on a Macintosh, for Macintoshes. I am hoping you will give downloading a try, and let me know how things go? Details on the page.
I started this collection sometime before September 2011. For many years before that, I had been building my collection of Delphi Tutorials. The things there will also inform your Lazarus work. (I've even made a few links from this, my Lazarus tutorials index, to pages actually in the Delphi collection. (I hope that no confusion is caused?) The overlap between Delphi and Lazarus is so extensive that in some cases I will use a Lazarus tutorial to help Delphi programmers, and vice versa.
If you find discrepancies between what a Delphi tutorial says happens in Delphi, and what you observe in Lazarus, please bring them to my attention, so I can save others hassle?
(If you are interested in seeing links to others' work, bookmark this page so you can get back to it, and visit my page with links. Of course, almost everything that anyone ever wanted to know is already on the web in Prof. Salmi's superb FAQs.... if you can find them!!! These wonderful resources are worth seeking out. 1/2009, they were available here. Fetch tsfaqp50.zip, unzip it, look in TSFAQP.IDX for the FAQ's table of contents.
(Those FAQs seem to move around! There were at ftp://garbo.uwasa.fi/pc/link/tsfaqp.zip, and then at ftp://garbo.uwasa.fi/pc/ts/tsfaqp36.zip. Hiding again? Try searching with Google for "timo salmi pascal faqs". I'm thankful they weren't written by Joe Smith!)
Pascal for those who know Basic... Some notes from me for those who know Basic, and who haven't done much Pascal.
Making it work... Help with debugging.. and on preventing the need for it.. Also useful to Delphi programmers.
If you want a bit of fun, even if it means dipping your toe into the hardware side of computing (but you can start gently), you might enjoy playing with the Dallas Semiconductor 1-Wire (tm) chips, as used on a MicroLan (tm). Although they are all couched in Delphi, they should be usable under Lazarus... if Lazarus can connect to the Dallas supplied driver. I think it can, but haven't tried it yet (!) (too busy writing tutorials for you. Give my 1-Wire programming tutorials a try, maybe? I also maintain pages which introduce MicroLan and explain the hardware.
I dislike 'fancy' websites with more concern for a flashy appearance than for good content. For a pretty picture, I can go to an art gallery. Of course, an attractive site WITH content deserves praise... as long as that pretty face doesn't cost download time. In any case....
I am trying to present this material in a format which makes it easy for you to USE it. There are two aspects to that: The way it is split up, and the way it is posted.
I have tried to split it up into 'bite-sized' pieces, and to indicate which pieces are basic and of general importance, and which address more specific issues which also happen to be complex, or require understanding of more fundamental issues. In other words, I try to show you how to walk before worrying about running.
The "Levels" into which the material is split is meant to help you find what you need as follows.
Things that are reasonably simple, or of general significance, or depend on few other concepts are in the lower levels. If a tutorial deals with complex or esoteric subjects, it gets assigned to a higher level. If you need to understand some basics before a tutorial will make sense to you, it goes in a higher level. If you have no experience, start with the low "level" tutorials. If you decide to jump in at a more advanced level, and things are not clear, it might be an idea to skim the topics in "lower" levels, if only to learn about my way of expressing the concepts. See also, below, the 'difference' between Delphi and Pascal.
For most readers, using the material online is your best bet. That way, you get the benefit of any updates to a page. However, that isn't always convenient. If you don't already have an HTML capable wordprocessor, load the free OpenOffice. It Really Does Work. Alternatively, you can save the pages from a browser, and re-load them to the browser from your hard-disc later, off-line.
If you choose to capture the tutorials for off line use, including editing for your own purposes, I would suggest that you create a folder for the tutorials so that you can retain my filenames with no risk of clashes:
Filenames: I've tried to be organized: Names start "Lt" for "Lazarus Tutorial". Next is a digit, for the level, then I've used letters one after the other, e.g. Lt1a, Lt1b, Lt1c. The letter doesn't mean much... it just shows when I got around to that particular topic! Sometimes the filename will have an uppercase "N" after the digit, e.g. Lt1Na, Lt1Nb, Lt1Nc. That is to indicate a "new" tutorial. If there is no "N", the tutorial derives from a Delphi tutorial I wrote some time ago. E.g. LT3r.htm would be a Lazarus version of my Delphi tutorial "Dt3r.htm".
Please remember the material is copyright. (TK Boyd, 2011 and later) The procedures above are suggested only for convenient personal use of the material, however, also....
Feel free to use this information in computer courses, etc, but a credit of the source, quoting the URL, should be present. If you simply copy the pages to other web pages you will do your readers a disservice: Your copies won't stay current. Far better to link to these pages, and then your readers see up-to-date versions. For those who care- thank you- I have posted a page with more information on what copyright waivers I extend, and suggestions for those who wish to put this material on CDs, etc. (There is at least one prison using the material for inmate education. I do understand that situations exist where an internet connection isn't possible!)
Speaking of giving credit where due... the following was a great help to my own programming: 'Borland Delphi How-To', from the Waite Group, by Frerking, Wallace and Niddery, ISBN 1-57169-019-0. Its approach suited my needs, and helped inspire the form of these tutorials: Most are self-contained explanations of how to accomplish a specific task, or use a particular component of the language.
In the beginning, there was Pascal, even before there was Windows. Gasp. A wonderful company, long deceased through excessive hubris, called Borland did a great deal to move the computer revolution forward with some wonderful products, notably Turbo Pascal. And they supported the educator and hobbyist.
Then Windows came along. And not long after, Borland created Delphi... sort of "Pascal for Windows".
Delphi used to be available to hobbyists and educators. Much less available today. But that's okay, because the Open Source movement, which has accomplished so many wonderful things, has given us Lazarus.... sort of a "free Delphi".
You can't just recompile a Delphi project with Lazarus, but if you know how to program with Delphi, you can do many of the same things with Lazarus... and your application can be ported to Linux, too! So Lazarus is sort of a free Delphi and Kylix.
Lazarus and Delphi are based on Pascal. They are for creating applications for Windows, using Pascal.. with a lot of enhancements. If you are very new to programming, you might make progress faster if you start with a non-Windows Pascal. There are free ones around, details of one can be found in my free Pascal tutorials, which I would commend to Delphi users with little experience with Pascal. (The one I recommend, freepascal, is the "engine" that underlies Lazarus.)
In the tutorials here, you should find all you need for Lazarus programming. However, even if you never intend to program for anything other than Windows, if you are new to programming, looking at some of the low level Pascal tutorials might help you to grasp important ideas for your Lazarus work.
(A version of the following note appeared at my Delphi site in May 2007) Kylix is a product Borland brought out years ago. It was a "Delphi for Linux". You take something written in Delphi (or write something from scratch, using the same skills), run it through the Kylix compiler, and, Hey! Presto!... You get an application to run under Linux.
I had hoped that Kylix would thrive, but it seems moribund. But Lazarus, oh please, seems to be the answer for those of us thinking that we need to move to Linux.
And, lastly, now for something (almost) completely different: Want a bit of fun? If you have the excellent, free, Open Office installed on your Windows or Linux machine, you can write applications similar to many of the applications in this tutorial! I've produced a little demo, consisting of a single "document" for Open Office's wordprocessor, "Writer". If you have Open Office on your machine, and download my demonstration, you will see a "page" of "wordprocessor" material with a button, an edit box, two spin boxes, and some labels, for output. You will see text manipulation, message boxes, and arithmetic. Almost like something created with Lazarus or Delphi! Fun! (The details of how the controls were made "live" are also given.) The demo was written for Open Office version 2.
The search engine is not intelligent. It merely seeks the words you specify. It will not do anything sensible with "What does the 'could not compile' error mean?" It will just return references to pages with "what", "does", "could", "not".... etc.
In addition to the tutorials for which this page serves as Table of Contents, I have other sites with material you might find useful.....
Delphi Tutorials (mentioned above).
Tutorials about the free database supplied with Open Office.
Some pages for programmers.
Using the parallel port with programs written in Delphi.
If you visit 1&1's site from here, it helps me. They host my websites, and I wouldn't put this link up for them if I wasn't happy with their service. They offer things for the beginner and the corporation.
Learn more about 1&1 Web Hosting
Click here to visit editor's Sheepdog Software (tm) freeware, shareware pages.
And if you liked that, or want different things, here are some more pages from the editor of these tutorials....
Click here to visit the homepage of my biggest site.
Click here to visit the homepage of Sheepdogsoftware.co.uk. Apologies if the "?FrmTut" I added to that link cause your browser problems. Please let me know, if so?
Click here to visit editor's pages about using computers in Sensing and Control, e.g. weather logging.
To email this page's editor, Tom Boyd.... Editor's email address. Suggestions welcome!
Page tested for compliance with INDUSTRY (not MS-only) standards, using the free, publicly accessible validator at validator.w3.org. Mostly passes. There were two "unknown attributes" in Google+ button code. Sigh.
Why does this page cause a script to run? Because of the Google panels, the code for the search button, etc. Why do I mention scripts? Be sure you know all you need to about spyware.
....... P a g e . . . E n d s .....