Science makes it known,
Engineering makes it work,
Art makes it beautiful.
D .dll Calling Pascal .dll - Pascal Files
Parsing Command Line Parameters Processing
The Pascal backend of
D .dll Calling Free Pascal .dll - D Files.
In both Lazarus and Object Pascal the command line parameters are
available via a call to function ParamStr (index), which returns
command line parameter as a string (it can be
returned to a char array variable). ParamStr (0) = the program's
name. In D, the entire command
line parameters are accessible by a single char*.
The Pascal .dll (allazrs.dll) consists of one Object Pascal file, one
Lazarus unit, and LCL units. The procedures and functions in
been successfully called by both a Free Pascal Windows program and a
Requires both Free Pascal
(for ALlazrs.pas) and
(for NumRecGlbl.pas and Interfaces.ppu).
originally developed for software reuse of user written unit
NumRecGlbl's command line parameter (ParamStr (i)
import library (not used for Pascal applications, required for D
applications - used when linking the D .dll in the D module's
and ParamCount) processing, as well as mapping a
1 dimensional array to
a 2 dimensional matrix, in a Free Pascal
In this application LIBRARY ALlazrs
procedure DCMDLINE (...) is called by D module
CmdLine procedure callDCMDLINE (...) as
part of D Windows program command line parameter processing.
allazrs.dll - ALlazrs.pas dynamic link library, compiled with
allazrs.lib - allazrs.dll
pragma (lib, "ALlazrs.lib") statement), built using Digital Mars
implib utility (file bup.zip).
units Windows and LCLType
(used by Interfaces) both define a
Window Handle type HWnd. Windows.HWnd is
compatible with both D
and Object Pascal.
Interfaces.ppu - Lazarus Component Library (LCL) component
unit description file; required for useing Lazarus unit
Object Pascal LIBRARY ALlazrs.
(In LIBRARY ALlazrs, recommend
explicitly defining HWnd handles as either type
or type LCLType.HWnd)
secondary unit used in Lazarus project
Lazarus, Free Pascal, Silverfrost FTN95, and Numerical Recipes;
contains command line parameter processing, file validation (when
file name included in command line parameters) using the Dos
unit, and indices mapping for a 1 dimensional array
to/from a TStringGrid, adapted for use via allazrs.dll in a
Free Pascal Windows application.
numrecglbl.ppu - NumRecGlbl.pas unit description file.
- include file developed from major rewrite of
(Free Pascal dawkins8.dll callable from both
Pascal and D programs); contains useful CONSTant and
- Numerical Recipes include file
hwndio.dll - used in Free Pascal
Windows programs, not used in
D .dll Calling Free Pascal .dll - D Files;
dynamic link library;
Free Pascal general purpose functions for Windows
Edit Controls I/O, field tabbing.
Procedure name must be upper case to be D callable.
Constants, variable iErr, functions
CurParamSwitch (...) and
cmdLnFname (...) defined in Lazarus unit
Call LIBRARY ALlazrs procedure DCMDLINE (...)
to search for/process input file parameter or artificial life related
D module CmdLine procedure prcCmdLine (...)
extracts a command line parameter from the char* command line
parameters list passed to the D main program by Windows, and saves it
in a character array. (prcCmdLine (...)
is primarilarly used for artificial life/simulated annealing
prcCmdLine (...) calls
D module CmdLine procedure callDCMDLINE (...)
(may call other procedures as well).
callDCMDLINE (...) calls
DCMDLINE (...) (examining the source code may help
to explain why done this way)
In addition to the -WR switch, fpcdll.bat will also need the
Library does not need them; or
can write another batch file, lcldll.bat for example, which
passes the above switches along with the
(the above values reflect my Lazarus installation,
which is on the D: drive, \lazarus directory; be sure to adjust the
additional switches to
reflect your installation)
To compile ALlazrs.pas and its associated files into allazrs.dll,
open a D2 32-bit Command Prompt and type:
(Can safely leave above additional switches in
fpcdll.bat if the Object Pascal
source file name to fpcdll.bat.)
To build allazrs.lib, in the same D2 32-bit Command Prompt, type:
implib allazrs.lib allazrs.dll
1. Press, William H., Brian P. Flannery, Saul A Teukolsky,
and William T. Vetterling (1986). Numerical Recipes: The Art of Scientific
New York:Press Syndicate of the University of Cambridge.
2. Rietman, Edward (1994). Genesis Redux: Experiments Creating Artificial
Life. Windcrest (McGraw-Hill).
The original Dawkins8 source consisted of one unit and one MS-DOS main program
(without any modularity whatsoever). Broke that down into two
callable .dll's (genecode.dll and dawkins8.dll) and one
include file. The main .dll is now very modular.