Sunday, February 29, 2004


 Delphi For Fun Newsletter #35


Happy Leap Day!


I try to get a DFF newsletter out every couple of months but missed the December issue – the last one was October 29th.  Some one finally asked what happened to it, so here’s a catch-up for the last 4 months.  My excuse -  “I’ve been sick”  (see January entries below).  Of course, not too sick to do things I found more interesting or challenging!  In any event, here’s info enough to catch you up if you haven’t visited the site in a while.   


November 5, 2003: The upcoming total Lunar eclipse on the 8th (or 9th, depending on where you live) finally prompted me to fix a few bugs and post the Astronomy Demo program written a couple of years ago.  This is a large program that may tell you more than you want to know about planetary events (and in more time and coordinate systems than you care to learn).  But if you want the details of the upcoming lunar eclipse, or the sunrise time when deer season opens next week, or where Mars is located in the sky right now - you may find this program useful.  As usual, friends down under can tell me what eastern events appear in the west, or daytime events appear at night, etc.,  and I'll fix things right up.    

November 10, 2003: I hope everyone got to enjoy the lunar eclipse Saturday night.    Don Rowlett pointed out a small bug in Astronomy Demo yesterday.  When using the "Planets" option from the "Actions" menu item, Saturn was omitted so all of the more distant planets got renamed and moved one orbit closer to the sun.  It's fixed today.   I also noticed that Pluto's orbital data is not available - the required parameters osculate (change over time) and accurate calculations for any date require data published for that year.  I didn't do that.  Perhaps I should have just omitted Pluto, but as it is  the message to that effect is just awkwardly presented.  

November 13, 2003:  Viewer Alexandre wrote asking about text-to-speech applications in Delphi.   I had idly wondered about it myself so checked it out.  Here's my Text-To-Speech  page with information about what you need and a couple of sample Delphi programs that will read to you, or create a sound file from a text file.    Don’t imagine that your reading days are over though - listening to robots talk can be frustrating, even if they are named Mary or Freddy or Mike. . 

November 16, 2003:

Tongue Click!

Last week I took my laptop to an 8th grade Science class where I do some tutoring.   They were studying waves and had fun making sounds and watching the resulting waveforms.   It did prompt me to start a  "Signal Generator " project that I hope to get posted in the next week or so.    Today's offering is Simple Oscilloscope, Version 2 .   The original version posted a year or so ago has been the most popular download from DFF.   The program captures sound card inputs and displays them in oscilloscope fashion on the PC monitor.   Version 2 adds a "Trigger" level control to produce more stable waveform displays.   Each scan across the screen can begin when the signal goes above (or below) a specified level.   I also added a "Single Frame Capture" button that uses the Trigger level to simplify capturing images of transient signal events.  


November 19, 2003:   Bouncing Ball  was one of our early postings, over three years ago.  It is primarily a programming exercise to animate a dropped ball with varying degrees of "bounciness"  (i.e. Coefficient of Elasticity).  Viewer Gerrit de Blaauw from the Netherlands recently found a fix for a bug that kept the ball from bouncing forever  when the Coefficient was equal to 1.  I posted a version of his fix today along with a few other minor enhancements

Nov 24, 2003:  We're off to play with grandkids for a week.  For you Americans, don't eat too much turkey this week,  For others, don't eat too much of anything else!   I'll catch up on the e-mails and post my new Signal Generator program when we get back next week.

December 6, 2003:  We are back!  Had a great visit but I've been under the weather for the last few days - not caught from the grandkids.   A 102o  (39o C) temperature makes hard to concentrate on computer stuff.

 I did upload a file today that contains executable versions of 50+ programs on the site.  I put it together a few weeks ago for use in our schools here.   The file includes an autorun.inf file and is intended to run from a CD but should run fine from a hard drive.  There's also a loader program, Programload.exe, used to select programs by category (Science, Math, Games, Puzzles, Tricks).  If you run it from hard drive or if auto start is not enabled on your PC, start by running the loader program, .     The file is  DFF Play  (zipped) , around 15mb in size.  There will be periodic updates with additions, deletions, and enhanced versions, so pertinent feedback with bug reports or suggestions will be appreciated as always.  


December 9, 2003:  Viewer Ricky requested a one-player version of the Hangman program.  One where the program was always the hangman and the human always the convict.   One player Hangman is now available for download from the Hangman2 page.  A brief addendum there describes the changes including the revised implementation of the "tricky" hangman.

December 14, 2003:   SoundGen is a program that lets you build and play complex wave forms through your PC's sound card as "Wave"  data streams.  

Sine Trumpet?
Composite Sawtooth Composite Square


 January 14, 2004:  Well, what a month!  As some of you know, I've been under the weather the past few weeks.  Short version of the story: sprained back, immobilized, blood clots in legs, pulmonary embolism  (clot moved to lungs), hospital week, blood thinner, fluid accumulation, ongoing recuperation.    One day I was age 65 feeling 45 and a few days later - 65 feeling 85.   Since the fatality rate of PE is about 15%, I’m happy to be here at all.  Whether and how much permanent damage was done remains to be seen.

The moral - do not take your health for granted!  Take seriously that stuff about frequent breaks while driving and hourly walks during air flights.   We all tend to feel immortal until we find out otherwise.   

Sometime this month, I did manage to respond to one of the many backlogged viewer requests.  Here is a High Scores  class object and test program.  The idea is to use an instance of the class to keep track of top scorers in games that you program.      

January 18, 2004: Recuperation continues.  Thanks for all the "get well" messages this week.  Main symptom now seems to be "dyspnea"  ("shortness of breath on exertion"  - serious illness will at least increase your vocabulary).    I can work at the computer for an hour or so per day now, so I'm doing some simple programming to check for brain damage.  

Here is a Text Search program requested by a viewer who has ambitions to make a bible search application.     The program searches a specified text file for a specified word or string.  Options include "whole words only" and "case sensitive".  Results are displayed with search string matches highlighted.   Perhaps a starter for someone with more specialized search requirements.


January 25, 2004: I bought a weather station (LaCrosse Technologies WS-2010) for my wife for Christmas.  Of course I had to get the PC Interface as well.  The software that came with it sucks (still trying to sort out software vs. hardware problems) so I have been working on a program to read data from the interface over the serial port and produce a file compatible with the file built by LaCrosse software.   The logic requires adjusting time stamps for local time zone so I wrote today's program, TimeZoneDemo, and posted it today over in Delphi Techniques.  It extracts and displays what Windows knows about our time zone settings.   

BTW, LaCrosse's support has been non-existent but perhaps they will get on the ball one of these days.   Currently my version reads the PC Interface information much better than theirs, but I may be just working around a hardware problem.  More on that story (and serial port processing) in the future. 


January 31, 2004: Just enough time left his month to catch you up on a few program enhancements made in the past week or two.  

Reaction Times is a program that measures viewer reaction times by flashing a target on the screen and measuring time until a key press or mouse click is received.  A professor at a Norwegian university is using the program for student projects in a first year psychology course.  He pointed out that I had used commas as field separators in the statistics file that are created.  Since many (some, most,  all?) Europeans counties use commas as decimal points, the files became very hard to decipher.  The program now  allows user a choice of field delimiter.   I believe that there are actually Windows system values for comma and decimal point which would handle the problem  more elegantly, but I was too lazy to look it up.

Peg Solitaire now has a "Custom" board type where user can define their own hole and peg configurations.  Viewer Philippe had requested this change and his problem board is now the default Custom board type.  I have not successfully found a single peg remaining solution yet for that board, but he believes that there is one.   I added additional solution definition criteria so that the Autosolve mode can now report "solved' when 4, 3, or 2 pegs remain.     

Circle Covering Points is a program that solves the problem of finding the smallest circle that encloses a given set of points.  My original version used a set of points defined by user clicks on the image.  A British company recently inquired about adding the ability to input a user defined set of real numbers as the points to be covered.   That change has been implemented and posted.   The application, by the way, is in determining the minimal hazardous area when the points being covered are the landing coordinates of some sort of military armament.

Finally, Big Combos has been reposted with a change to allow up to 10,000 combinations to be displayed, up from 1,000.    Viewer Graham needed to see all 1820 combinations of 4 items selected from 16..   I wish I had found out why.

My programs to read and chart data from the PC Interface for the Lacrosse Technologies WS-2010  (WS2010) weather station are now working.  I probably will not post the code because of the small potential audience - but I'll be happy to send it on anyone with this weather station who is interested..   


February 10, 2004: Here are a couple of more Delphi Techniques demo programs I wrote this week.  I plan to leave my weather station data capture program running, so it makes sense to use the Systray area to access it and save taskbar space.   Here is a Minimize to Systray demo that shows what is required.  It’s mainly a matter of figuring which Win API functions control the appropriate windows and icons. 

Also, a few weeks ago I described a problem in the Reaction Times program when I used comma as a field separator in the statistics files.  This was fine here, but a user in Norway reminded me that they also use commas as decimal placeholders - making it quite difficult to make sense of the resulting files!   I corrected that problem by offering a choice of delimiters but thought that Windows really knew what character was used locally as the decimal placeholder.  It knows that and more than 100 other items of information about your country or locale.  Here is a Locale Constants demo that shows how to access the information.  

February 14, 2004: The first time I tried a practical application of the "minimize to tray" code posted a few days ago, I decided that it needed simplifying.  Today I posted SystrayDemo2 which uses an excellent freeware CoolTrayIcon component written by  Troels Jakobsen.   With a few small changes, it only takes a couple of additional lines in the program to implement minimizing and restoring apps from the tray notification area (a.k.a. the Systray).   

February 22, 2004:  A daughter gave me Bill Bryson's book "A Short History of Nearly Everything"  a while ago.  At 500 + pages, it's not so short, but it is the most interesting book I've read in the past year so  I'm passing it on as my "book of the month".    Each time I pick it up I  learn new fascinating facts about some science - Geology, Archeology, Astronomy, Oceanography, Biology, Chemistry, Physics - name a physical science and chances are that Bryson will tell you something about it that you didn't know.   He sometimes poses simple questions for which no one knows the answer.  

 Here are a few examples from my current chapter,  "Small World" 

14,000 people per year die in U.S. hospitals of infections they did not have when they were admitted.
A kind of slime mold starts life as a single celled spore.  When food is scarce, 100,000 or so of them somehow get together and form a slug that can travel to a more desirable location.  Eventually,  when conditions are better, the cells of the slug transform themselves into a stalk (built from cells) topped by a ball containing spores (built from other cells) which are released to start the cycle again. 
The Great Swine Flu epidemic of 1918 resulted from a mutation of common flu strains and killed an estimated 20 to 50 million people, the worst in history.  Most people who contracted it died.  Even today, scientists do not know where it came from, where it went, or why it largely bypassed infants and the elderly, concentrating its deadly effect on those in the prime of life.   (Or when it might happen again!)  
If you totaled all of biomass on earth, 80% of it would be made up of living things too small to be seen by the naked eye! 

A great book for teenagers considering possible vocations.  Now I just need to find one that is as well written and that emphasizes mathematics, engineering, and computer programming before my grandkids make their choices.

February 17, 2004:  It's been a while since we posted an new game or puzzle. Here's a PC version of the classic memory game, Simon.  Delphian Shane Holmes wrote it with a few changes by me.  The computer generates increasingly longer sequences of lights and sounds that the player must duplicate.  The game ends when you make a mistake.  My record so far is 12.  I'll bet the grandkids can do better. 

(Feb 26 – family champion so far is 7-year-old Luke. with a correct 20-note sequence on his first try!  All those hours playing Lego Racer must be paying off!)

February 23, 2004: When I posted Simon last week, I discovered that the Windows Beep procedure used to produce the sounds does not work under Windows 95, 98, or ME.  I found and used a substitute procedure that outputs directly to the PC speaker for those systems.   Here is a BeepEx Demo posted in Delphi-Techniques with the replacement beep procedure details.  Also shows how to generate an equal tempered musical scale if you are into that sort of thing. 


Gary Darby


" Seize the moment of excited curiosity on any subject to resolve your doubts; for if you let it pass, the desire may never return, and you may remain in ignorance” - William Wirt (US Attorney General 1817-1829)

To subscribe or unsubscribe from this newsletter, visit

 68,000 home page visitors since Sept 2000.     190,000 programs downloaded in the past 12 months!