Y · E · L · L · O · W       P · A · G · E · S

 

Autumn 2008

 
 

How I learnt to
* P R O G R A M *

 Bruce Coleman
 

 This article curtesy of Archive Magazine
Vol. 21   N°. 10   September - October 2008

 
~ I'm not a programmer ~
~ Not by any stretch of the imagination ~
~ but ~
~ I do dabble a little ~
 

Many years ago I had a workmate who, like me, was a retained firefighter at the local fire station. The station held an annual charity fundraising which, in my first year with them, was in aid of Great Ormond Street Hospital. The proposed event was a sponsored 24-hour pool marathon. I suggested we could run a sweep where people pay 50p to guess the number of shots played in 24 hours. The nearest guess, I explained, would win a prize. My workmate thought this a great idea and said he would get some sheets printed up. At this point I offered to make them on my A3000 using !Draw. The event was a great success.
 
Place your bets
The following year's event was a charity horse-racing night. My interested in computers declared, I was asked if it were possible to calculate the odds of each horse, dependent on the amount staked. In effect, a totalizer system was wanted. Each race was a film of an American six-horse race. Punters placed bets on the horse they fancied.
 
My program was written within 24 hours and displayed the names of six horses along with each horse's odds. The stakes were in units of 10p: placing a bet of £1 on horse N°. 1 involved pressing the "1" key 10 times and so on. All of this was written in Mode 6 on an Acorn Electron.
 
The next program I wrote for the firefighters' charity work was a timer and scoreboard for a "Pot the Lot" speed pool competition. This game offered a prize for the player who downed all the balls in either the shortest time or the fewest shots (or both, if possible). The program showed the current player's name at the top, a clock in the middle and the current leaders for both competitions at the bottom.
 
A single press of the spacebar set the clock running, and another press stopped it. I had to program in a delay for keypress-checking, because some users were pressing the spacebar twice, which immediately stopped the clock. The results of each frame were sent to a disc file that kept everything up to date. If for any reason the computer went down, the program loaded the data from disc and was back on track. The results were also sent to my faithful Brother HR5 thermal printer so they could be checked.
 
When I got my RiscPC I came across a module that played any WAV file from a BBC BASIC program using a star-command. I modified my horse-racing program so that while bets were being placed the computer occasionally said "Place your bets!" It sounded a fanfare at the start of each race.
 
Snoop and adapt 
This was my introduction to !Run, !Boot and RMEnsure. I learnt by inspecting other people's programs, REMming out lines to see what effect they had and checking the Programmer's Reference Manuals when I came across a SYS call.
 
A year or two back there was a request on the Archive-online list for a utility that would save a screenshot when the PrtScn key was pressed, à la Windows. Obviously this had to be multitasking. I had a utility called !WindowRd by Jason Tribbeck which saved the window beneath the pointer to disc at the press of a certain key combination.
 
So I opened it up, inspected the code and found the magic key in the "wimp poll" section. Once I had seen how it worked, I was able to cobble together various utilities for my own use, including a screen-grabber.
 
Capslock warning
When Jim-the-editor asked on Archive-online if it were possible to have a beep sound to warn him when he pressed the CapsLock key by mistake, I knew that a simple mod to one of my utilities would suffice:

REM >BeepCaps
END=&10000
SYS "Wimp_Initialise",200,
          &4B534154,"Caps Beep"
DIM point% 256
REPEAT
SYS "Wimp_Poll",,point% TO snap%
CASE snap% OF
WHEN 0 : IF INKEY-65 THEN VDU 7
ENDCASE
UNTIL FALSE

 
Here is BeepsCaps set up on an Iyonix. It's been turned into a tiny application. The BBC BASIC BeepCaps program is the !RunImage file, a !Run file has been added and the two of them placed inside a !BeepCaps directory. Launch the application in the standard manner by clicking on the !BeepCaps directory.

 
Jim put this into his Boot.Tasks directory so it is automatically run as his machine starts. He asked me to explain in an article what the code does but I don't feel sufficiently knowledgeable! Like most motorists I know what to do but I don't know why I am doing it. Perhaps a reader could write an article for Archive about these programming techniques.
 
Bruce Coleman is a retired electrician living at Yarm, Teesside. He worked in the motor trade and heavy industry for many years.

 
 
 
 

 
 
 

 
 
 

 
 
 
 

 
 
 

 
 
 

 
 
 

 
 
 
 
 
 
 

 
 
 

 
 
 

 
 
 

 
 
 

 
 
 

 
 
 

 
 
 

 
 
 

 
 
 

 
 
 

 
 
 

 
 
 

 
 
 

 
 
 

  
 
 
   
   
   
   
   
   
   
   
   
   
   
   
 

*INFO     A · R · C · H · I · V · E

   
 

 
Under editor Jim Nagel, Archive's been going from being a good RISC OS magazine, to a great one. Regular as a quartz clock and heaving with content, the annual (12 issue) subscription has remained the same for years: £45 UK, £50 Europe, £56 rest of world.
Furthermore, the entire contents of 20 years of Archive are on a double CD (or a DVD) for £19, indexed.