Royal Genes


Safe For Kids





computer fun... :)



Sat, 29 Apr 2006 16:16:34 GMT alt.fiftyplus
previous


david...
a long time ago... somewhere in the mid 1970's, one of the computer
languages i used was called SIMSCRIPT.... i used it to simulate various
processes...

well, i stumbled onto this simscript program that i felt even the non
computer folks would enjoy... Well, you need to first be familiar with
the song "99 Bottles of Beer on the Wall"... :) you may need to read it
twice, but if you're singing along, you'll see the logic... i think it's
a beautiful example of computing logic...

'' this defines the variables... brewer, drinker, bottle
PREAMBLE
PROCESSES
INCLUDE brewer, drinker
RESOURCES
INCLUDE bottle
DEFINE countem AS A INTEGER VARIABLE

END

'' this initiates the 'brewer'.... starting with 100 bottles
MAIN
CREATE EVERY bottle(1)
LET U.bottle(1) = 1
LET countem=100
ACTIVATE A brewer NOW
START SIMULATION
PRINT 1 LINE THUS
No more bottles of beer on the wall.

END

'' this loops through the 'drinker' 99 times (for 99 verses of song)
PROCESS brewer
FOR I=1 TO 99
DO
ACTIVATE A drinker NOW
LOOP
END

'' this prints the words of the verse, reducing number each time
'' requesting a bottle and then relinquishing from shelf/consuming...
PROCESS drinker

REQUEST 1 bottle(1)
RELINQUISH 1 bottle(1)
LET countem = countem - 1

IF countem > 1
PRINT 3 LINES WITH countem, countem THUS
** bottles of beer on the wall.
** bottles of beeeeer ...,
Take one down, pass it around,
ELSE
PRINT 3 LINES WITH countem, countem THUS
** bottle of beer on the wall.
** bottle of beeeeer ...,
Take it down, pass it around,
ALWAYS
IF countem > 2
PRINT 2 LINES WITH countem-1 THUS
** bottles of beer on the wall.

ALWAYS
IF countem = 2
PRINT 2 LINES THUS
One more bottle of beer on the wall.

ALWAYS
END
next