HOME       Delicious.Com  Bookmark this on Delicious     StumbleUpon.Com Recommend to StumbleUpon

Pascal Programming Tutorials

I give details of three good free Pascal compilers further down the page.

An aside: I became excited about the Arduino microcontroller a few years ago. It uses a C-like language, but if you can program in Pascal, you can learn to program the Arduino without great effort. You say "goodbye" to Pascal's finger- annoying ":=", but semicolons remain a "little joy" to contend with. There was some Arduino material here, but that is now on a page of its own: Arduino programming and use.)

Someday, please read the introduction and guide, further down this page? No need to do that now, if you want to get going on...

This article, as it stood at 12 April 2013, is also available translated to Serbo-Croatian language by Web Geeks.



Tutorials Table of Contents

To search this site....

Press the enter key after you enter your search words. Powered by FreeFind
Site search

Level 1 Tutorials:

(Versions ("FPK", "TP", "Pascalite") explained in the introduction and guide to the site.)

Start Here FPK version: Setting up. And some general points.
Start Here TP version: Setting up. And some general points.
Start Here Pascalite version: Setting up. And some general points.


Second tutorial FPK/TP version: Going loopy.
Second tutorial Pascalite version: Going loopy.


Third tutorial FPK/TP version: Introducing variables.
Third tutorial Pascalite version: Introducing variables.


Fourth tutorial FPK/TP version: More on variables.
Fourth tutorial Pascalite version: More on variables.


Fifth tutorial FPK/TP version: Counting in binary. ("For" loop)
Fifth tutorial Pascalite version: Let there be light. ("For" loop and LEDs)

Revolution counting: What has that hamster been up to? (One version for all three flavors of Pascal.)

Arrays tutorial FPK/TP version: Super variables
Arrays tutorial Pascalite version: Super variables

User Defined Procedures FPK/TP version: Make your own language! (Part 1)
User Defined Procedures Pascalite version: Make your own language! (Part 1)


Level 2 Tutorials:


At 6/07, the Pascalite thread is the most mature. The FPK/TP thread is a work in progress. Until FPK/TP specific pages become available, readers are invited to study the Pascalite page.
Not a tutorial. The rest! (Miscellaneous features introduced)

User Defined Procedures: Make your own language! (Part 2- parameters)

Generalized Rules of Program Structure: Let's have some backbone! (A hard and not ESSENTIAL tutorial covering some basics)

Program Structure Suggested by Pascalite Default: (Not essential, but may help if you want to use default.)

Things You Could Do: Sketches of some ways to use a Pascalite


Level 3 Tutorials:

User Defined Procedures: Make your own language! (Part 3- more on parameters)

Generalized Rules of Program Structure: More backbone!

An Overview of Binary Mostly theory.


Which Pascal compiler should I use?

Details of some good free Pascal compilers

Free Pascal (aka FPK Pascal)

FPK Pascal: I discovered the delights of FPK Pascal, aka "Free Pascal", (and this was also once known as "FPC Pascal"!) in June 2007. In November 2011, I still strongly suspect that this is your best bet for an introduction to Pascal in a easy- to- use environment. I've written a separate page about its virtues, setting it up, and a small test program you can use to see the installation went okay. I will be very disappointed if this Pascal is not capable of serious work. It is also the basis of the Lazarus Project, could almost be called a "free Delphi"... i.e. a GUI for producing Windows applications... but it does Linux, too! I have only "played with" it a bit... but enough to start some Lazarus tutorials for you! Lazarus is one of the "write once/ compile twice" multi-platform wonders which I hope will gain strength. They allow authors to sell to two markets for only one creative effort!

I wrote the following before getting started with Lazarus, which is much more attractive to me than Java... but that may be my Delphi background showing. If you liked Delphi for producing Windows applications, and now you want to program for Linux, and you are not afraid of learning something new and different, i.e. Java, then perhaps you might want to consider NetBeans. It is considerably more "mainstream" than any Pascal based program development tool I am aware of for Linux. I don't think the change to Java will be a big deal for anyone who could work in Delphi. I've done just a little playing with Netbeans, but am happy so far. I'm using it under Ubuntu.

(This note added December 2008) Well... I'm using Linux quite a bit now... Ubuntu... and I found a copy of Kylix on eBay. Can't get it to install, though. Sigh. Maybe Java via Netbeans is the way to develop applications for Linux? I fear Kylix may be dead. A great pity. If people are using it happily under Ubuntu, I'd be delighted to hear from them. I found the install issues beyond me.

(That note went on to say, "Maybe try Lazarus?" I didn't know Lazarus then as well as I know it now. And Lazarus did not yet have the track record it now has. I can now (11/11) be more enthusiastic, and say, "Give Lazarus a try!")

I will be working through the tutorials on this site, doing FPK versions of them for you because I like this open source product so much.

I have used part of the FPK system on a Ubuntu (vers 7.04) Linux box. I am very new to Linux, and have (so far) only managed to get the command line version of the compiler working... but that DOES work (for quick "Hello World" tests). I hope to get the IDE working in due course. From the FPK forum, it seems others have got it to work.

Borland Turbo Pascal: Traditionally, we used Borland's Turbo Pascal as the industrial strength, de facto "standard" Pascal. You can obtain a free copy of the powerful version 5.5, but it does come from "pre-Windows" days, and is less "Windows friendly"... although it, and the applications it produces, will run, in MS-DOS windows. I have prepared a separate page about installing Borland's Pascal, (with a first project, to test the installation). That is written primarily for XP users, but it will work... probably better... on earlier Windows, too.

Pascalite: Pascalite compiler: While less widely supported than the other two, less "powerful", this one has some special strengths. It makes very little demand on your system. It has an impressive simulator for the hardware "Pascalite" that was once available. It was a microcontroller which ran Pascalite code, and Pascalite is equipped with special commands to access the microcontroller's inputs and outputs, which include ADCs and counters. (It was a bit like the wonderful Arduino which we have today.) While I'm not sure the hardware is available, or will ever be again, Pascalite is still wroth consideration as a learning tool. The software... including the simulation of the hardware... was still available, still ran fine on my main machine of the time (an XP box), in November 2011

Recommendations: If you have not done much programming, or much Pascal programming before now, perhaps you should start with FPK Pascal, or Pascalite. FPK Pascal and Pascalite work more easily than the Borland product (legacy from MS-DOS days) under Windows, and are easily removed from your system if you grow beyond their strengths. In October 2008, I said that FPK seems more "alive" than the Pascalite, and that still seemed true in November 2011. If you are not forced to stay with Pascal, for a microcontroller development package, I'd strongly recommend an Arduino. That would mean switching to C, but even if you've half learnt Pascal, you have what it takes to learn as much C as you need to run the Arduino. It is not a big transition.




Introduction and Guide to these Pascal tutorials

This site offers you a sequence of lessons which should help you master Pascal programming. You don't need to pay for a compiler: the tutorials can be followed with any of the free Pascal compilers. All run on Windows, from Win98 to XP, and more modern versions of Windows, too, I believe. FPK can also be used on Linux boxes ('Ray!) and Macs. Thus, the material should be of general use. Feel free to use the tutorials in programming courses, but a credit of the source would be appreciated.

You can follow two threads through the tutorials. One is for users of Free Pascal, aka FPK. That thread will also help users of Borland's Turbo Pascal. The other thread is written with users of the Pascalite in mind.

If you follow the Pascalite thread through these tutorials, you do not have to have the Pascalite hardware to do most things in these programming tutorials. If you do have the hardware, especially if you have just obtained it, please have a look at my Using the Pascalite Hardware It has details of how to access various features of the splendid Pascalite.

Pascalite is two things: A Pascal software programming package which you can download for free, and an inexpensive microcontroller, which is remarkably capable. The software includes not only the compiler, but also a splendid integrated working environment including editor, debugging tools and simulation of the Pascalite hardware. The download was only 482kb in late 2002, but don't be fooled into thinking that it can't be very capable in so "few" bytes. It simply wasn't written at Microsoft. (In November 2011, the download was about the same size, but the file date had been advanced to 2006. I tested it on my main machine of that time, an XP box, and it worked fine.)

The original home of Pascalite was http://www.controlplus.nl/ Today, you go to http://home.planet.nl/~basti976/pascalite/index.htm for the software and, and to watch in case the hardware becomes available again. That site is mainly in Dutch, but if you click the "English, please" button, then most of the pages... not all... are presented in English. By the way, the site hosting the page you are reading, and the tutorials, were created without payment from or affiliation with Control Plus. I just thought the product deserved publicity, and liked the fact that I could teach Pascal without costing my pupils any money. I have also done an overview of the Pascalite for you.

Whichever thread you follow, be it the FPK/TP or the Pascalite thread, the exercises should work exactly as presented if you are using the intended environment. In addition, both (mostly) obey the rules of any good Pascal and they will give you a good start on other good dialects of Pascal.

Delphi, the Pascal based Windows application creator, is a much under-rated programming tool. And Lazarus derives from that and looks set to thrive and prosper. Delphi is not as easy to obtain, for hobbyist use, as it once was. My advice? Put your energies into Lazarus. But if you can get your hands on a version of Delphi which doesn't leave you hostage to whatever company is selling it this week, go for it! Not just with Delphi, with all non- open source programs: Beware the "promotional" or "introductory" or "SE" ("special edition") versions. Often they are merely ploys to get you hooked, when then "reel you in". Do you know the wonderful Uncle Remus stories? Br'er Rabbit and the Tar Baby comes to mind. See my Delphi Tutorials site for more information on these matters.







Other Tutorials by me, not integrated with the above:

Introduction to Dallas 1-Wire... Overview and links to tutorials with source code for accessing 1-Wire (aka MicroLan) devices, as used in iButtons. Dallas is now part of Maxim. ("1-Wire" is a registered trademark. The Pascalite hardware can access at least some 1-Wire devices, at least a little. I would guess that more functionality will be forthcoming in due course.)
Pascal for those who know Basic... but who haven't done much Pascal.
Making it work... Help with debugging.. and on preventing the need for it. Also useful to programmers using other languages.


       Editorial Philosophy

I dislike 'fancy' websites where there's more medium than message.... especially if that means I have to wait while multiple little items get downloaded. 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 may also be more complex, or require prior understanding of other issues. In other words, I try to show you how to walk before running. The 'Level 1' tutorials cover the basics. If you have no experience, start with the level one 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 level one topics if only to learn about my way of expressing the concepts.

The way it is posted...

You should be able to read the tutorials on-line without difficulty. However, you should ALSO find it easy to capture them for off-line use, including editing for your own purposes. The following should work. I would suggest that you create a folder for the tutorials so that you can retain my filenames with no risk of clashes:

On-line, use your browser to view the tutorial you want to capture.

Use your browser's File|Save As... to save the web-page to your disc. At this point you can log off or visit other pages, perhaps saving them, too.

When you have logged off, use your browser's File|Open file to access what you saved.



Filenames...

I've tried to be organized: Names start "plt" or "pt" for Pascalite / Pascal Tutorial. Next is a digit, for the level, then I've used letters one after the other, e.g. ptl2a, ptl2b, ptl3a. The letter doesn't mean much... it merely shows when I got around to that particular topic! And, appended to all of the above, you will sometimes find a "p" or an "f". These indicate that the file is a "Pascalite" or "FPK/TP" version of the tutorial, respectively, when present.





The connection between Pascal and Delphi and Lazarus and Kylix:

Delphi is based on Pascal. It is for writing programs for Windows, using Pascal with a lot of enhancements from those wonderful people at Borland. I've worked hard for years developing a collection of Delphi tutorials.

Delphi inspired the open source Lazarus. Delphi also gave rise to Kylix, which was "Delphi for Linux", but which, as I discussed elsewhere, I fear is dead. Happily, Lazarus is a "write once, deploy twice" language: The same code will create a Windows app or a Linux app, depending on how it is compiled.

If you are very new to programming, you might make progress faster if you start with a non-Windows Pascal... such as any of the compilers the tutorials on this page help you with.




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 Programming Tutorials/p>

   Using a Windows / DOS PC's parallel port with programs written in Delphi and other languages./p>

   The Arduino Microcontroller.... very affordable, lots of fun!/p>

   Some pages for programmers.



And now for some links to some pages which you may find useful, written by other people.

They will be opened in new windows, so use your tabs (Opera, Firefox), or just close their windows (IE) to get back here.

(Please do not ask me to list your page here unless your page already has a link to my page, and your page has been up for at least two years. (And I can confirm that with the WayBack Machine.))


Before you have looked very far on the internet for help with Pascal, you should encounter Timo Salmi. Almost everything that anyone ever wanted to know is already on the web in Professor 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!

Programmer's Heaven Not just for Pascal, but for a vast array of resources for programmers of many languages and platforms. Code snippets, tutorials, guides to what tools are available, etc, etc!
Borland Once user unfriendly, but not last time I looked. Certainly worth a visit. The registration information they ask for is less presumptuous than many sites. Free copies of not primitive versions of the excellent Turbo Pascal are sometimes (legitimately) available.
Delphi Land- Delphi tutorial, tips, source code. English or Dutch (Nederlands)
Frank's Delphi Lessons (LS, 1/04, 10/04, (new URL 6/06), 5/07)
Marco Cantu's Essential Pascal tutorial... read online, or download text.
Babilon: Tutorial written for beginners, but with some intermediate level tricks, too. Was at: http://www.babilon.com/delphi/tutorial.htm (Bad link, 2/2010)
Delphi Super Page.... an archive of material, some with sourcecode.
Swiss Delphi Center In English, German, and French. Programming tips, Downloads, Links, Etc
www.matlus.com: Site with straightforward tutorials dealing mostly with building using Delphi 6 Enterprise. (Dead link, 2/2010)


Alternatively, use newsgroups,

Google's Groups to obtain answers to your questions! (New to newsgroups? See my introduction.)



To search THIS site.... (Go to my other sites, below, and use their search buttons if you want to search them.)
Click this to search this site without using forms.



powered by FreeFind
Site search Web 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"....

Please also note that I have two other sites, and that this search will not include them. They have their own search buttons.

My site at Arunet.

My Sheepdog Guides pages, another of this page's editor's sites.


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 an MS-DOS or 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 freeware, shareware page.



Link to editor's (Arunet) homepage

Have you heard of Flattr? Great new idea to make it easy for you to send small thank you$ to people who provide Good Stuff on the web. If you want to send $$erious thank yous, there are better ways, but for a small "tip" here and there, Flattr ticks a lot of boxes which no one else has found a way to do yet. Please at least check out my introduction to Flattr, if you haven't heard of it? "No obligation", as they say!


How to email or write this page's editor, Tom Boyd


Valid HTML 4.01 Transitional 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.