Search
As of October, 2016, Embarcadero is offering a free release
of Delphi (Delphi
10.1 Berlin Starter Edition ). There
are a few restrictions, but it is a welcome step toward making
more programmers aware of the joys of Delphi. They do say
"Offer may be withdrawn at any time", so don't delay if you want
to check it out. Please use the
feedback link to let
me know if the link stops working.
Support DFF - Shop
If you shop at Amazon anyway, consider
using this link.
We receive a few cents from each
purchase. Thanks
Support DFF - Donate
If you benefit from the website, in terms of
knowledge, entertainment value, or something otherwise useful,
consider making a donation via PayPal to help defray the
costs. (No PayPal account necessary to donate via credit
card.) Transaction is secure.
Mensa®
Daily Puzzlers
For over 15 years
Mensa Page-A-Day calendars have provided several puzzles a year
for my programming pleasure. Coding "solvers" is most fun,
but many programs also allow user solving, convenient for "fill
in the blanks" type. Below are Amazon links to the
two most recent years.
Mensa®
365 Puzzlers Calendar 2017
Mensa®
365 Puzzlers Calendar 2018
(Hint: If you can
wait, current year calendars are usually on sale in January.)
Contact
Feedback:
Send an
e-mail with your comments about this program (or anything else).
|
| |
I spent much of this month (March, 2013) revisiting conversion of Delphi programs on DFF
to the free Lazarus/FPC compiler. The effort was prompted by a viewer
email saying the process has much improved recently. It has! Lazarus
is a front end integrated with FPC (the Free Pascal Compiler). The
guys that work on Lazarus have done an amazing job,
particularly considering that they try to support multiple platforms.
I am not a Lazarus expert and do not intend to become one. To test
compatibility, my approach has been to port some DFF programs to Lazarus on
Windows without trying to maintain compatibility with Delphi. This
simplifies things a lot since, for example, no changes were required to any
Delphi programs during this exercise.
If you play with what is provided here or try other DFF
programs, please let me know about my errors/oversights/misunderstandings
and your successes or failures in other areas. Lazarus has
dozens, perhaps hundreds of options, most of which I have left at default values
except as described here. If you branch off of my path, you will likely
have to turn to the Lazarus community for assistance.
I started with the a dozen or so programs which use DFF library units because
most DFF programs use at least something from the library. Structurally, I
have a Library folder on my system where all of the units contained in the
library zip file shared
DFF units reside (currently
DFFLibV15) . Lazarus versions reside
on my computer in a folder named LazLib.
There is nothing special about this except all Lazarus projects using library routines
will need a unit search path pointing to LazLib or your equivalent. A zip
file of the Lazarus converted library units, DFFLazLibV01, is available
here.
Here is an Index of Lazarus
Conversions.
With that much background, here are some rough notes about what I have done, who
I have done it to, and what I've learned. (Latest additions are in
red)
|
Converting
projects from Delphi: Here is an outline of the steps I used to
successfully convert a number of programs from the DelphiForFun website:
-
Installed
current Lazarus version
-
Defined a new
LazLib folder to contain current Library units that are required
and a Lazarus folder to contain the converted programs.
-
Copied
library units to be converted from Library to LazLib
folder.
-
Selected a
program to convert and copy the xxxSource.zip to a new subfolder
in under the Lazarus folder and unzip it there. (The source .zip
provides an easy way to restart the conversion process if necessary.)
-
Started
Lazarus and, for the first project, select Project/Project
Options/Compiler Options/Path/Other units. Select and add the path
pointing to Lazlib for the first conversion. Also select the
first path Template, $(LazarusDir)\lcl\units\$(TargetCPU)-$(TargetOS),
and add it to the units path, Select "make this the default for future
new projects" before clicking OK. (The Lazarus units template is not
normally required, but it does no harm and was needed in one case for a
library unit which has no form, but calls the "application.processmessages"
method defined in unit "Forms".)
-
Selected
Tools/Convert Delphi project and selected the .dpr file from step 4.
Unchecked all option check boxes except "Keep converted units open in
Editor".
-
After
converting, errors may be detected in the conversion process or during
the first execution. Most errors have been encountered so far have been
when converting one of the units failed. (Converted units will have a
{$MODE Delphi} statement near the beginning of the
unit.) There is a Tools option to convert a
single unit only which seems to work well if a specific incompatibility
in that unit has been fixed.
-
(April 6, 2013): Wordstuff3 conversion required
installation
of the LazJPG component, adding a Project-Options-Paths path to the
LazJPG location in Components/Images folder and replace JPEG with LazJPG
in the project uses clause.
-
Converting Delphi .dfm form files to text before
running the Project conversion eliminates some errors when the converter
eliminates some unused Delphi form properties and then complaind the the
variables are missing.
|
|
Keyboard differences added for compatibility with my Delphi
|
Added Ctrl-PgUp
and Ctrl-PgDn as move to absolute top and absolute bottom |
|
Added F2 and
F3 as Save current and Load current. |
| I
have not located a "Persistent Blocks" option in Lazarus, so my
habitual use of the the Ctrl K keyboard shortcuts for "Start block",
"End Block", "Copy Block" and "Move Block" is requiring some retraining.
on my part. |
|
|
Compiler Message Differences
|
Issues "Not
initialized" hints message for arguments which are "var" parameters
whose value is to be set by the called routine. |
|
|
Gotcha's
|
Lazarus
searches for units in subfolders of the project folder before checking
unit search path specified in options. If you have left an out of date
library unit in a subfolder used for testing, it will be used for the
current project with possible negative results. |
|
Loading a
project (.lpr) file using the File/Open menu does not close the current
project or open the new file as a project. Must use Project/Open menu
item. In Delphi, opening a .dpr project file makes that file the
current project. |
|
In Delphi,
Unit search paths are global and fully qualified. Unfortunately, in Lazarus they are
tied to each project and relative to the folder containing the project.
So if a library name changes or it is moved, the change must be made in
all existing Lazarus projects. There is an option with each local path setting
to make it the default for all new projects thereafter.
|
|
Files open
in the Editor can only be closed by right clicking on the page caption
for that file. In Delphi a right click anywhere in the edit area
include a "Close" option the popup menu. |
|
At Close
time for a project, Delphi asks if changes are to be saved only when
source code has been modified. Lazarus asks after any compilation,
probably because one or more of its status or history files has changed.
|
|
IDE windows
do not "autodock" to other windows. E.g. in Delphi I routinely dock
Watchlist to bottom and Object Inspector to left side of Source Editor
window. |
|
While
debugging with the program Paused, Delphi will display the current value
of a variable if the mouse hovers over it. Not so in Lazarus.
|
|
TCanvas does not have "Height" or "Width" properties in either Delphi or
Lazarus, but use of those names within the scope of a Canvas control
causes problems when Lazarus tries to call a TCanvas.GetWidth method.
|
|
Deleting and re-adding PrintDialog dialogs fixes problems with using
that feature. |
|
GetTextMetrics has differences in the calling sequence and in the record
format returned, apparently because Lazarus uses a version compatible
with non-Windows platforms, even when compiling for Windows.
|
|
|
Advantage
Lazarus
|
Full path of
files open in the IDE is displayed in status line at the bottom of its
page. In Delphi it can be difficult to discover exactly where an open
file lives. |
| Lazarus has the similar
visual design alignment aids as in current Delphi bersions (but not my
Delphi 7). |
|
| Programs &
Units converted
| Library units: These
unit are available in DFFLazLibV01.zip on the Library download page.
| DFFUtils.pas |
| Mathslib.pas |
| UBigFloatV3.pas |
| UBigIntsV3.pas
|
| UComboV2.pas |
| UDict.pas (&UDict.frm) |
| UGeometry.pas |
| UIntegerPartition.pas |
| UTGraphSearch.pas |
|
| Lazlib Test Programs:
These are available for downloading on the individual program pages as Lazarus
source code download links. Minimal testing has been done other
than seeing that they compile and start execution OK on my system. A new
Lazarus category has been created so that an index of programs with
Lazarus conversions can be created. (Index is not working yet.
I'll check into it).
|
| Other Programs
|
|
|
Specific
Conversion Issues
|
Sudoku - Had
to typecast TStringGrid to TDrawGrid for call to
AdjustGridSize. Delphi accepts Tstringgrid as argument, Lazarus
does not (but it should). |
|
Ugeometry -
|
TImage
Fillrect: Delphi calls Windoows.Fillrect. Lazarus uses
Picture.Graphic if it is assigned (i.e. if program has drawn
on TImage.canvas. In this case, image is redrawn, not
cleared. Workaround: Set Picture to Nil before calling
Fillrect. |
|
TSpinEdit
should ignore Maxval & Minval values when they are the
same. Lazarus does not. Workaround: Set Maxval to 1000 in
Spinedit1 and Spinedit2 |
|
Change
variable Erase to DpErase in DrawPoly -
TFPCCanvas has a conflicting Erase procedure, Delphi
Tcanvas does not. |
|
Change
function Line to MakeLine in UGeometry because
TFPCCanvas definition has a conflicting procedure Line,
Delphi TCanvas does not. |
|
|
| Links
|
Original: March 27, 2013 |
Modified:
May 15, 2018
|
|