[Company Logo Image]

Home AR4 Palletiser OPC Programming Wintek32 Delphi Downloads

Delphi Odds and Ends


In the course of developing a diverse range of software we sometimes produce generally useful bits and pieces which may be of interest to other developers, particularly those who use Borland Delphi.

Parsing and Evaluating Pascal Expressions

Parsing and evaluating expressions written in Pascal is a simple matter for the compiler, but a bit of a problem to do at runtime. Simple expressions like:

4 + 2

or more complicated, like:

(Pos('an', 'that is not an edible fruit') + 4) <= (62 div 4)

Can be evaluated by the routines in prExpr.pas. There are a number of parsers which will evalulate arithmetic expressions. This one is different, in that it can handle mixed type expressions. It supports four basic types: String, Float, Integer and Boolean, as well as most of the functions of the Borland Pascal system unit. Making the most of this parser is not a task for the faint-hearted as it has mechanisms for supporting arbitary identifiers which are powerful and hence a tad complicated in places. The documentation is reasonably complete and the distribution zip has a few simple examples to get you started.

Also available is exprhelp.zip (123kB) which contains the source material (rtf/hpj) for compiling the help file included with the above file.

The latest version of prExpr is a bit fancy. It uses interfaces as handles to expression objects. This makes allocation and disposal of objects a lot less complicated, but can be confusing for those who are not comfortable working with interfaces. It can be a bit strange until you get used to it. prExpr104 also handles class references (you can dereference published classes in expressions) and Enumerated types. If you you can't be bothered with all that an are possibly familiar with prExpr version 1.03 you can still download the older version expr103.zip.

Delphi Source for OpenGL Screensaver

The Win32 SDK comes complete with Source code for the OpenGL screensavers that ship with NT4 and Win95 OSR2. I thought it would be a nice idea to produce a version showing the AR4 palletiser zipping about, but the port from C to my favourite language was a bit of a struggle. In the end, I started again, bringing together information from lots of different sources. The example is compiled with Delphi 5.01.

Tiny Delphi Win32 Application

Often I have to write a small utility program that monitors something or installs something but I cannot bear the thought of loading the whole of the Delphi VCL just for a form with a couple of buttons. In these circumstances I write a minimal Dialog based application that uses the Windows API. mindlg_pas.zip (2kB) contains the source code to an example of a such a tiny program. The compiled program is 18kB.

Cross Process Buffer

In Windows NT each process has its own address space. If you want to pass data to another process this can be a problem. One way around this is to allocate some memory in the address space of another process then use that to pass the data, using a Windows Message. All you need is the window handle of the target window. I was surprised that it was possible to do this. Example programs ('client' and 'server') are in xpbuf.zip (5kB).

Capture the Output of a Console Application

If you have ever tried to run a console application and capture the output, you may have tried to make sense of the topic in the Win32 help files called 'Creating a child process with redirected input and output'. When I found this topic, I thought I had found all the answers. It turned out to be a bit more complicated than I thought. If you want to skip the questions and go straight for the answers, then download console.zip. (30kB)

Debugging using a Mono Screen (Win95 only)

We write a lot of 'design time' Delphi code, and find that a quick and easy way to do simple debugging is to use an old fashioned Monochrome Display Adapter (or Hercules Graphic Card - the old 720x348 card) to receive debugging messages. prCrt.zip contains a VxD and a unit which assigns a custom textfile device driver to System.Output. This means that you can sprinkle writeln() though your code and the output will be redirected to the mono screen. The VxD also handles BEL (ascii 07) in a special way which makes it very useful for testing high speed periodic routines. This has been tested with D2 and D3 and may work with D1.0. Windows 95 only.

Not many people use this, but the ones that do really like it because it is so simple.

Read the comment block in prCrt.pas for further instructions.