HOME      Other material for programmers

I have notes for translators, if you would add a translation.

There used to be many translations here. Unfortunately, the translators cheated... initially, the links in the translations took users directly to the relevant page, as required by the license to translate. Then they changed the links, to pull traffic to their sites, hurting my SEO status.

This page, as it stood Oct 2017, is available in French, translated by Avice.
This page, as it stood Oct 2017, is available in Portugese, translated by Artur Weber who does technical translations
This page, as it stood Nov 2017, was available in Estonian at crowfer.com/lazarus-programmeerimine-opetused. Let me know if you find that has returned to the web. It was missing, 4 Sep 2019.

My thanks to these kind people... and I hope you'll send them your thanks, too!


Lazarus Programming Tutorials

(filename: lut/index.htm)


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 Windows, Linux and Mac?

You've come to the right place!

Not installed your Lazarus yet? Using Windows? then please check this note if you have a 64-bit machine ! ! ! !




For many years I worked in Lazarus's predecessor, Delphi. I also offer many "Delphi" tutorials and "how to"s which in many cases are as valid for Lazarus as they are for Delphi. If you try one, and find it NOT suitable for Lazarus, Please let me know


See Also: Lazarus / Delphi Course:

Further to my longstanding Delphi tutorials and "how to"s, I have a series of essays which try to help you become a good Lazarus/ Delphi programmer. You will only get the benefit if you take the time to work your way through them. The Tutorials can be tackled in whatever sequence suits you, and are more suited to "dipping into". The essays of the Lazarus/ Delphi Course are most useful if read in sequence. Lazarus/ Delphi Course Table of Contents




Good news!

(Well, I was excited by the following:)... In August 2016, I finally got around to trying to use Lazarus to do things with the Dallas 1-Wire family... their excellent temperature sensing chips (DS1820, DS18B20, DS1822, etc) are popular.. but usually used in a very limited way. They can be so much more than is usually done with them... and their are other chips in the family.)

Lazarus played nicely with the Delphi SDK from Dallas.

Sourcecode and explanation for a "hello world" (reads a DS18B20) program. From there, there are links to more general pages about what 1-Wire/ MicroLan, etc is all about.

Challenges!

I've put together a little challenge if someone wants to "play" with it. (Or set it as homework to some students!). It merely asks you to write a little code to solve a problem. There's lots of help with how to go about it.

((Image http://sheepdogguides.com/lut/Angles-unslid.png))

The challenge is to calcuate an angle from the x,y coordinates of of three points which are assumed to be connected by two line segments defining an angle.

You can download the sourcecode of the shell of the program.

---

A "middling-difficult" challenge: Write some of the code it would take to create a program to "read" answer sheets for multiple choice tests and surveys.

---

Another challenge: Ths one is a much bigger challenge... but I genuinely believe it can be achieved. It is in two parts... I can see a 12 year old achieving the first part- capturing images simulating the operation of a CT scanner, and a 16 year old achieving the second- writing the software to turn the captured images into a picture of what the "CT scanner" "saw".




Lazarus on Raspberry Pi!

I've put together a few (two, when this was edited items about using Lazarus (vers 1.6.2) on a Pi. It works! (Pi 3 B, August 18... I only had to do two sudo apt-gets. Works! Easy! Fun!)




Some highlights of the collection, good starting points:

  Hello World 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.



Table of Contents, Lazarus Tutorials:

Level Zero Tutorials:

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.


Long ago, I installed Lazarus on my Windows XP machine without any drama. (First install: 26 July 2011, vers 0.9.30 for 32-bit Windows.) and subsequent installs (and upgrades on Lazarus equipped machines) have mostly gone well, too, the latest being the install of version 1.6.2 on a Windows 7 machine. (Which went without incident.)

In fairly distant 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. Probably down to my DNS.

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. (Unless you want to maintain two versions?)

What you need is at https://www.lazarus-ide.org/index.php?page=downloads. for Windows, anyway, you don't need any of the fancy "compile the source" stuff that some "installing Lazarus" pages talk about.

It's pretty straightforward, but if you'd like help, you are welcome to what's in my brief "Installing or Updating Lazarus" note.



Please at least skim though the following "Level Zero" tutorial before attempting to use others from this page. If you already have significant Lazarus or Delphi experience, you should be able to fly through it, but besides introducing you to Lazarus (or Delphi), it also shows you some of my basic working practices and establishes some terminology.

Hello World 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. "Hello World" is long and perhaps tedious, but I really do recommend it to you strongly.

There is other important stuff in Where to put things, how to create backups. Not all of that will be immediately accessible to some readers. The more trouble you take over it, the more often you return to it until all of it does make sense to you, the faster your Lazarus skills will develop. The material is touched on here and there in many of the early tutorials, but the matters discussed will distract you until you are fully on top or them.



Level 1 Tutorials:

A few little early exercises- Gently Does It Once you have mastered the basic skills in my Hello World (in Level 0, above), (and have made a start on understanding what is in the "Where To Put Things" guide) 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 https://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.

Unusual format: five .pdf's, with supporting text in the webpage. Between them, they try to help you understand where things in the .pas file, the code for a unit, came from... This knowledge is very helpful from your earliest Lazarus or Delphi programming days. The essay also tries to explain what the things on the unit are.

Tips and Tricks You don't need this tutorial now, if you are just getting started. But here is a list of ideas of things I would encourage you to consider including in every app you write.





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. Making a clone. Not difficult. Only placed in Level 2 because this isn't something beginners need to struggle with.

Arrays (plus Encryption- for fun) In simple terms, "arrays" are a super powerful sort of variable. This essay tries to help you get started with these remarkably useful things, and works up a program to encrypt text, just by way of making the whole thing more "interesting". (You don't need to interested in encryption to benefit from the essay.)

Overloading You don't "need" this... but a quick note to explain it, in case you come across someone using it, and could be puzzled.

File transcription- first way Don't be alarmed if when you use this link, and find yourself in Delphi- land! (Uses AssignFile, Reset, Rewrite)

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.

File transcription- the second, better way A new tutorial, written in late October 2017. The job it does isn't so very different from the job "File transcription- the first way" did... because that job exercises various tools of reading and writing data from and to disks. A less fully developed, but more fully explained example of using filestreams is contained within my tutorial on working with RTF files.

But this time, the job is done a better way. A way with perhaps a slightly greater "bump" at the bottom of the learning curve, but, a Just Better way. You can do it! You know you want to! Uses Filestreams.

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: Postscript to the previous tutorial, a frill for that structure for building a "do these things, one after the other" loop.

Using the Anchor Editor... illustrated with a little application which I hope you will find "fun"... it puts four images on a window, and you can resize to your heart's content, the images stretching to keep the window filled. But that's not "the point" of the tutorial. The point is to have a simple example of the Anchor Editor in action. You don't "need" to use the Anchor Editor to get things done... but if you want "professional" applications, in which components move around, and resize nicely when users resize the overall window, you will want to use the Anchor Editor.

(Subroutines- to plug into your own application) DrawTools... Some subroutines you can "plug into" your application, to "wrap" your drawing of lines, changing of pixel colors in easy to use subroutines. Done in a manner anticipated to be novice-friendly. With sourcecode. See also next...

(Subroutines- to plug into your own application) DrawTools- More... Further to the previous tutorial. Some subroutines you can "plug into" your application, to "wrap" your drawing of lines, changing of pixel colors in easy to use subroutines. This incorporates the same subroutines as the previous tutorial, without explaining them much, and adds some more advanced material. With what's in this, it is easy... once you understand how the subroutines are to be called... to create graphs, including graphs, say, of weather data as it arises. You add dots at the right hand edge, and the graph gradually scrolls left, with "old" data "dropping off" the left edge as the process proceeds. Tools are present for scaling the data. You know your sensor returns, say, 23 to 78? You want those dots (in green) to occupy the middle third of your graph? The latest reading will be in iTmp? No problem! Call something like DoIt(iTmp,23,78,33,66,clGreen); Full sourcecode provided. (As usual) Free. (As usual) Should work with Delphi, too.

Just The Code- LINK TRIGGERS DOWNLOAD OF ZIP... In a break with my usual format, this link will start the download of a .zip file of Lazarus sourcecode, rather than taking you to another web page of text. ("LDN177.zip")(The .exe that sourcecode produces is included in the .zip). Windows 10's "Windows Defender" moans, initially prevents the app from running. But if you click the "More Info" link in the Windows Defender dialog, a "Run anyway" button appears. (You can... and should!... scan the file with your anti-malware software before running it, of course.)

Someday I will give it a tutorial! But for now, it is something for you to play with, and figure out for yourself! It puts a grid of small colored squares on the screen, and had buttons to redraw the graphic after making changes to the colors of the squares. Provided as a starting point for your own experiments with color.

AND, similar... another "Just the code" zip.... a little "thing" that draws a circle of "LEDs" on the screen for you to play with. (A simulation of my Arduino project with ring of Neopixels.)





Level 3 Tutorials:

Multiple windows/ Passing objects to subroutines: This is an "odd" tutorial, but one I commend to you. It doesn't chase any particular useful outcome... but along the way you will encounter various useful techniques. Quite a long tutorial, but, like vegetables, Good For You, I think. It is one of my old Delphi tutorials, but annotated to help you with some tiny Delphi/ Lazarus differences. Full Lazarus sourcecode supplied. "Pop up windows", among other things.

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... but with some flaws, alas. (It is about a somewhat esoteric topic!) The good news is that it comes with complete sourcecode for a basic "copy selected files from a folder" application, which can be adapted for your wants, and studied for something that does work, regardless of any flaws remaining in what the tutorial says.

*** Entry point, a huge topic > > >   Using data in files consisting of similar lines of data... perhaps a .csv dump from a database? (Or something put together by hand with a text editor, e.g. Notepad or Textpad.) Not a trivial subject, but very, very useful general skills. Addressed in a small series of tutorials.

Getting hardcopy- CORE of printing multiple pages from a Lazarus app. January, 2021, i "went mad". Spent days on different matters relating to getting Lazarus/FreePascal to put ink on paper. Although the "multiple pages" part might put you off, don't let that worry you. If If you want to print stuff, start with this short (500 word) sketch of the code at the heart of anything that puts ink on paper.

Getting hardcopy- Printing from a Lazarus app: The nice people at FreePascal did a page about how to put ink on paper with Lazarus- "Using the printer". I've written that up twice. The link at the start of this paragraph will take you to a "second edition", written in January 2021. It has a link to the earlier version which is less polished, but has some details not present in the second edition. At 7/19, and they seemed to be present still 1/21, there were a few little "things" in the "official" page which might be a nuisance for you. I have tried to explain. Especially if you are getting "Error... exception class 'External: SIGSEGV'. In file 'printers.pas'... result:=(pfPrinting in fFlags)" when you try to use Printer4Lazarus, you might want to read my guide/ corrections.

Getting hardcopy- More on printing from a Lazarus app: As you can see from the previous entry, I've put several things on the web for you. The others cover the basics, should help you "get started". This on covers more advanced use of the ideas set out in the earlier ones. There is little in the way of "tutorial" with this one... but there are a few notes, and you can download the whole Lazarus project sourcecode. It is full of internal documentation. Download sourcecode of LDN161- printing ink-on-paper formatted text, and/or graphics, with Lazarus.

Decimals to Hex.. or even base 41! Two small bits of code. Small but (mostly) complete. Perhaps useful... and probably instructive. Alas, most of the "webpage" is inside the sourcecode... but it is more fully commented than usual.

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.

A boilerplate, with some encrypting/ decrypting routines to illustrate what it can do: At 1/19, this was new... and, if I may say so myself, pretty good! The "tutorial" is mostly in the downloadable source code's comments. The application, as presented, is "about" encrypting and decrypting text in TMemo objects. But that part of the code is trivial. It is just a way to illustrate Doing Things with the contents of a memo. Some even more generally useful Good Practices come up along the way, too.

JUST a download, at this stage: (5.9MB... includes some images) Skeleton of a program which lets you "mess with" images. One button loads an image from disc. A second creates a new image from the first, according to whatever rules YOU put into the code. Back of job broken for you.

Predator/ Prey Population Dynamics Simulator: If you find the "hand holding" present in some tutorials more than you want, this may be the one for you. Although it is ostensibly about modeling an ecosystem, the same techniques are useful in any "generational" scenario. The simulation will win no biology prizes. (But it has a strong framework, and if you know the biology, building it up to account for more of the biological aspects could be interesting.) But, if you study the tutorial and the supplied sourcecode, you could learn things about supplying a fairly common computing want. The link above takes you to the first of two tutorials. The second extends what was done in the first.

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.

A long tutorial with two big objectives: Not for the faint hearted! But in the course of this long tutorial, ostensibly about something which may not interest you (!), I expound on the idea of the computer as a "state machine", and programming to reflect the computer when seen as such. (The thing that may not interest you is how you might convert an old program written in BASIC into a program written with Lazarus.) (The program being discussed is the wonderful early home computer version of the Cave Adventure game "Hunt the Wumpus", from PCC's fabulous "What to do after you hit Return".)

More on "state machines", "state diagrams": November 2018 I discovered that I have little on my tutorial pages about "state machines", "state diagrams". The thing is, I've never studied the topics "properly"... but for some time I've been using a "state machine" inspired approach in some of my programming. While there may be mistakes in how I go about these things, I commend the previous tutorial, which is all "in" Lazarus to you, and also one I wrote for the Arduino community. You don't need to want the ostensible content either to benefit along the way from the talk about creating state machines, and some of the things that go into planning the implementation of something by those means.

The term didn't appear in it until recently, when I revised it, to insert a preface, but my essay on "Structure: Planning, testing" was written when I was beginning to grasp the usefulness of thinking of programming as the creation of state machines.



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:

(Besides the Level 4 Tutorials described below, if you want to learn about using Lazarus to draw graphs, there is, along the way of other matters, a graph included in the "fancy" version of the Predator/ Prey simulation, listed up in Level 3.)

Competition! Prize money! Can you turn a file of encrypted text back into the human readable material it once was? (Remember that the journey can be as much fun as the destination. This will not be cracked easily.)

RTF files and Filestreams: RTF stands for Rich Text Format. It was one of the earliest ways to put color, different font styles (bold, italic...) and sizes into a document. It has its uses today. In passing, this also talks about filestreams... perhaps more usefully than my earlier filestreams tutorial (lt2Ne-filestreams.htm) yet does. The sourcecode is provided, and comes with a copy of the stand-alone .exe that it creates.

Using "Units" in Lazarus (or Delphi) programming: It can e very helpful, in a "divide and conquer" sort of way, to use secondary units in your Lazarus programming. Follow the link at the start of this paragraph for hours of work, Sept 2020... when I'd been writing these things for many years... to see a new attempt to persuade you to use this major aid to productivity. Towards the end of it, I say that "maybe records can be used." It would seem I did manage to use records previously. They seem to be part of my earlier attempt at this topic....

I also offer an earlier attempt at this topic: Older guide to using "units" in Lazarus (or Delphi) programming. It covers more or less the same ground, but sometimes reading something "twice" can be helpful to a student. Let me know what you think.

When that first attempt was published, I said of it...

It will pay you to master the "extra", and "unnecessary" skill of splitting up your code into a main unit supported by subordinate units. Not only does this make staying on top of a large project easier, but, as your skill gets stronger, you will begin to find that some sub-units can be "shared" between projects. As an aside, within the tutorial, I again visit user-defined records, which can be seen as a way to create "custom" data types.

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, looking 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?!

Make barcodes from texts: This is one of my "tutorials" that has most of the didactic material in the comments contained within the sourcecode provided. (Click second link for a .zip with the Lazarus sourcecode, and a copy of the stand-alone .exe for creating barcodes from text.) It takes text, and puts it, as simply as possible, into a Code 128 barcode. You will need to have a Code 128 font on your system. I found a good one, available for free download (without registration) from https://www.wfonts.com

StringGrids: One of my better tutorials, I would say... but perhaps not addressing "core" issues. Careful and thorough, though. It looks at taking a CSV file, putting it in a string grid, (TStringGrid object), vetting the data in some columns, highlighting those that fail the tests. The user can then, by hand "fix" the bad data. And ultimately re-save the data as a new file of CSV. I wrote the code for my own wants, in appending data to an OpenOffice database in batches, but many generally useful issues explored. The tutorial should also be useful as an account of how something non-trivial is built up in stages. Sourcecode provided, as usual. If you only need the bit about loading a CSV file to a StringGrid, see the next tutorial.

Load a StringGrids from a textfile This SMALL tutorial covers JUST how to load a StringGrid from a simple CSV textfile. It was written at the same time as the larger tutorial, above. It covers one of the key elements which work together to create what is accomplished in the larger tutorial. Sourcecode provided.

Rough example of two useful things: This is in a rough state, but introduces two things... 1) The very generally useful user defined record. It takes a while to see why you'd want to use them... but once you grasp that, they are great. Particularly useful for returning multiple values from a subroutine. (About the only good way to do it!), and... 2) Reading from a file, a textfile in the example, "the old way", with AssignFile (we called it "Assign", but that got used for something else, causing no end of hassle, until the old "Assign" became "AssignFile") and Read or ReadLn. Very useful when you want to read a bit of a file, without reading all of it. Sometimes that doesn't matter... when the file is small. Also allows you to append things to files, but that isn't covered here. (Grasp what's here, and appending is a quick stroll in the Google Search park.)

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.

More XOR!: This tutorial is a little different... not much in the way of "tutorial", but quite a large application, complete with sourcecode as is often the case here, demonstrating XOR in action. The sourcecode is more than usually polished. Written 10/17... much better than some of my efforts from 15 years ago when I was getting started with this sort of thing. The demo includes some really simple things, and two rather more complex things. If you think they're not so special, try recreating them without looking at the source code. First there's one, then two then three then four icons on the screen. Then as a fifth appears, the first disappears. Then a sixth appears, and the second- to- appear disappears. And so on.


Level 5: TCP/IP...

At the moment, the best I can do for you if you want to interact with the internet (or just with an intranet), is to refer you to section five, the of my Delphi tutorials. I have to warn you that the material is dated, and I was just getting started with TCP/IP programming when I wrote them.

Which TCP/IP Units:... help choosing a set of units to support your TCP/IP work. Why I like the free suite from http://synapse.ararat.cz/. (Sadly, that resource is only available via an http (not httpS) link at 10 Sep 23. I wouldn't be greatly worried by that in this case. I always scan downloads with my anti-malware software... rarely get red-flags when something's been around, been good as long as Synapse. (You'll find information about Synapse in the Lazarus wiki. the download link there (10 Sep 23) is "http://www.ararat.cz/synapse/doku.php/download")

Getting set up: Fetching and "installing" the Synapse TCP/IP suite.

Yet Another View Page Source. WHY?: The code in this short tutorial gives you a little utility to view the source of any web page. It also gives you a quick test of your Synapse installation. (Synapse: Free library of IP/TCP stuff). and it gives you a "skeleton" which could be expanded to do many useful IP/TCP things, particularly in the field of maintaining your web presence.

A nice simple "Hello Internet" Thing: Sourcecode and tutorial for a simple project. (A compiled .exe you can Just Use also provided.) The .exe allows you to send something to any web-server, be it on your LAN, or out on the internet. By this "sending something" you can make an IP Cam take a picture, or an Arduserver change the state of its LED (and if you can change an LED, you can change LOTS of things... from across the internet.) And yet, the exercise is quite simple, and an easy first exercise, if you haven't done a lot of TCP/IP yet.


Dallas 1-Wire, by Lazarus and otherwise...

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 chips, as used on a MicroLan (tm).

Lazarus sourcecode and explanation for a "hello world" (reads a DS18B20) program. From there, there are links to more general pages about what 1-Wire/ MicroLan, etc is all about. (That page has a link to an index of Lazarus 1-Wire material, but I must admit that the "index" doesn't have to list very many pages yet! The "hello world" tutorial is the best, at the moment.)

ANOTHER VERSION of Lazarus sourcecode and explanation for a "hello world" (reads a DS18B20) program. This is for people already used to Lazarus and to 1-Wire... but is very similar, fundamentally, to the other two, above. If you find it hard to follow, try one of the more introductory versions.

In addition, although they are all couched in Delphi, they should be usable under Lazarus, once you've put the {$mode delphi} into iBTMEXPW.pas unit, near the top. Give my 1-Wire programming tutorials a try, maybe? I also maintain pages which introduce MicroLan and explain the hardware.




Miscellaneous Matters- including Macintosh:

I should 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, eventually, 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?




A word about Pascal, the "foundation" of Lazarus and Delphi.......

(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 Professor Salmi's superb FAQs.... if you can find them!!! If you can find where they've gone, 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 ftps://garbo.uwasa.fi/pc/link/tsfaqp.zip, and then at ftps://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 Tutorials:

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.




Editorial Philosophy

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.

The way it is split up...

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.

The way it is posted...

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, install the free LibreOffice. 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.




The relationships between Lazarus, Delphi and Pascal....

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 or MacOS, too! So Lazarus is sort of a free Delphi and Kylix.

Lazarus and Delphi

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, Libre Office installed on your Windows, Linux or Mac 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 Libre Office's wordprocessor, "Writer". If you have Libre 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... but I am taking it on fatih that it will also run under Libre Office... the heir to the crown falling off the head of the mortally wounded Open Office.





Use this to search THIS site.... (Go to my other sites, below, and use their search buttons if you want to search them.)

index sitemap advanced
search engine by freefind

Site Map    What's New    Search

The search engine merely looks for the words you type, so....
*    Spell them properly.
*     Don't bother with "How do I get rich?" That will merely return pages with "how", "do", "I"....


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



Ad from page's editor: Yes.. I do enjoy compiling these things for you... hope they are helpful. However.. this doesn't pay my bills!!! If you find this stuff useful, (and you run a Windows PC) please visit my freeware and shareware page, download something, and circulate it for me? Links on your page to this page would also be appreciated!

Click here to visit editor's Sheepdog Software 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 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! Please cite "SheGui/lut/index.htm"



Test for valid HTML Page has been tested for compliance with INDUSTRY (not MS-only) standards, using the free, publicly accessible validator at validator.w3.org. It passes in some important ways, but still needs work to fully meet HTML 5 expectations. (If your browser hides your history, you may have to put the page's URL into the validator by hand. Check what page the validator looked at before becoming alarmed by a "not found" or "wrong doctype".) Mostly passes.

AND tested for  Test for valid CSS

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 .....