FPC Free Pascal: An opensource treasure

For many years, I have been working on an ever expanding collection of tutorials on using the excellent Borland Delphi. Delphi is based on Pascal, so, along the way I've had an interest in Pascal.

I'm also interesting in "kicking the Windows habit". In connection with that, I've kept an eye on Borland's Kylix.

In June 2007, while researching current views of Kylix (not encouraging), I came across the Wikipedia entry about FPC Pascal. It looked fantastic, and I gave it a try. First impressions are very good, and I expect to be expanding the "FPC version" material in my Pascal Tutorials page.

Why do I like FPC Pascal?

I won't belabor any of the above points except the last. What is "the Lazarus IDE"? It is, I think, a "free Delphi", with cross platform capabilities.

Now! Please be advised: I've written one 5 line program with FPC Pascal, and I haven't even explored the Lazarus site. But I have a Very Good Feeling about both. And about 35 years of programming experience.

Even if Lazarus is unsuccessful, which I have no reason to expect, but a "free Delphi" is almost too much to hope for, but, even if Lazarus is unsuccessful... the free FPC Pascal may well be the answer to the many, many people who would like access to a good programming language, with cross platform capabilities, and a very attractive price.

Based on that belief, I am going to spend some time writing "How To's" for you.

The official FPC Pascal site has, of course, lots and lots of good stuff for you, not least install guides which are much slicker, and much better informed that the following.

On the other hand, maybe you'd like an "unbiased" impression of FPC Pascal, and a report of my installation experiences on a Win98 SE machine? Good. That's what fills the rest of this page!

Getting started with FPC Pascal on a Windows machine

What follows doesn't take you down long paths, nor reveal dark secrets. I hope you will read through it and be encouraged by how smoothly everything went for me. I expect you would have as smooth an experience.

(I'm only going to say "FPC" from now on, not "FPC Pascal".

First I went along to the FPC download site. Once there, I selected ver 2.0.4 binary for "Windows 95, 98, ME, NT, 2000, XP"

Downloaded fpc-2.0.4.i386-win32.exe, which was 28 MB of material.

I didn't have to register, log in, supply email address, or any other nonsense. I just fetched the file I wanted, saved it on my hard disk.

As is my cautious practice, I then copied the download to a "scratch" folder, in case of mayhap (there was none), and double clicked on it. A normal Windows install ensued.

N.B.: There's a comment in one of the FPC FAQs to the effect that folder names with spaces in them can sometimes cause problems. The FAQ suggested installing FPC in C:\PP. But the installer suggested C:\FPC\2.0.4\, and I went with that.

As usual, "Custom install" was one option. There were two mandatory components:

I ended up accepting everything. The stuff that seemed not too important too very little space. The following were among the larger optional elements:

The Windows API units may be things that you won't need until you go beyond creating console applications (what you will do for a while, if you don't know what that means)... but, especially if you begin to work with Lazarus, I expect the day will come when you want to move beyond console applications, and when you do (if not before) you're going to need those Windows API units. Go on. Install them now. Be ready!

(I wasn't too sure what the FCL and GTK components were, so I thought I'd install them, just to be safe!)

The installer offered to set up 2 config files with defaults; I accepted the offer.

In less time that it took to launch on another machine a game to pass the time, the install was done!

That's it! You're "good to go". You might want to delete the scratch copy of the install package, just to be tidy.

Now for an account of day- to- day use of the product....

A first program

The installer will have put a "Free Pascal" entry in your "Start" menu, in a folder called "Free Pascal". Double click on that. A DOS window should open almost immediately. At this point, don't worry! It looks as if something's wrong, or as if the computer is waiting for you to enter some command. Be patient! After what will seem an age until you are used to it, "stuff" will appear in the window, not least a menu bar and an edit window. Don't worry... once "awake" it runs as fast as it should. (On my reasonably fast (for it's vintage) Win98 machine, it just took 40 seconds.) ** WAIT FOR IT!!! **

Outside FPC, using Windows Explorer set up a folder of the following name, with spaces if you want them, although having none may be safer. (I use "TKB", my initials, in place of "My" in things like the following. If you have similarly non ambiguous initials, I recommend you do the same. MS loves to dump things on your disk called MyThis, MyThat, MyTheOther... and how do you tell them from things you wanted?)

C:\My Documents\FPC- MyPrgms\MyFirstEverFPC

The FPC- MyPrgms folder is a "container" for lots of other folders. I generally use a new folder for each project. Apart from anything else, it saves me being clever about ReadMe files. I have lots! But I know from the folder it is in what a given one applies to. Having separate folders may be overkill. See how you get on.

Then go back into FPC, and enter....

program FirstFPCPrgm;
uses crt;

writeln('Hi, 21 June 2007');

(You can, by the way, use your mouse, and you can use Windows copy/ paste... with a slight "nod" to the fact that you're in something that also runs on Linux, and which, on Windows, is working as in the MS-DOS days of old. To copy from Windows, into the FPC editor, as you might want to, to save transcribing the above by eye and finger, you copy the Windows source as you would normally (select required material, press ctrl-C). You then click inside the FPC editor and use the "Paste From Windows" option under the "Edit" menu item. (To do the opposite- copy from FPC to Windows- you select the material you want, use the "Edit" menu item option "Copy to Windows", move to whatever Windows application you wanted the material in, and do a normal Windows paste (ctrl-V)

Request "Run" from the menu, and then "Run" again from the sub-menu. Or just use Ctrl-F9. A Save As dialog will pop up. Navigate to the folder you created earlier. Note: To go up the folder tree, click on the ..\Save the program as "FirstFPCPrgm".

You may have typos in what you entered, in which case you find and fix them and try run again. (You say "Yes, I know; now go away." to message boxes by clicking the little square at their upper left.)

Eventually, the program seemed to run, but I found myself back in IDE after only a glimpse of a white- on- black screen with "Hi, 21 June 2007" on it. The "trick" is to open a persistent "Output" window. You need to click Debug | Output AND invoke Window | Tile. Note that "restored" windows can only be re-sized by dragging their lower right corners. the window can be moved by dragging the title bar. You can switch between windows with F6, and switch the current window between maximized and restored with F5.

The people at Borland were very early pioneers in the use of windows. You could do windows in Turbo Pascal before you could buy Windows!

The IDE has syntax highlighting, oh joy!

Much of the IDE is reminiscent at first meeting of Borland's Turbo Pascal... but in FPC, the mouse works properly without hassle. (You can get it to work with TP, too.)

All worked well... and I didn't even have to re-boot the system after the install! :-)


   Search this site                 powered by FreeFind
Site Map    What's New    Search

Click here to visit my homepage where you can explore other areas, such as education, programming, investing.

Looking for email, domain registration, or website hosting? If you visit 1&1's site from here, it helps me. They host my website, 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.

Ad from page's editor: Yes.. I do enjoy compiling these things for you. I hope they are helpful. However... this doesn't pay my bills!!! Sheepdog Software (tm) is supposed to help do that, so if you found this stuff useful, (and you run a Windows or MS-DOS 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.

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

Why does this page cause a script to run? Because of the Google panels, and the code for the search button. Also, I have my web-traffic monitored for me by eXTReMe tracker. They offer a free tracker. If you want to try one, check out their site. Why do I mention the script? Be sure you know all you need to about spyware.

....... P a g e . . . E n d s .....