RetroRetrospective

RetroRetrospective – Fun today with yesterday’s gear……..

May 8th, 2013

Programming like we did back in the day.

Programming, Random Thoughts, by Michael.

There is a new podcast coming from the Retrobits family by Earl Evans for all us  ‘ancient’ programmers.  Called “?NEXT WITHOUT FOR” it aims to discuss retro programming languages and systems, as well as new tools for current systems for creating programs to run on the old iron.

This got me thinking and remembering, that back in the 80’s and 90’s I used a mainframe document generation system called DCF (Document Composition Facility http://en.wikipedia.org/wiki/SCRIPT_(markup)) and as well as a GML (Generalised Markup Language) extension it had quite a powerful scripting language itself.

One inadequacy that I encountered early on using DCF, was that there was very little loop control/processing available, so I created my own FOR/NEXT command, and to celebrate Earl’s new  “?NEXT WITHOUT FOR” podcast, I’ve decided to post the code for my FOR and NEXT commands.These commands allowed me to create single and nested FOR/NEXT Loops using similar syntax to many languages of the day, especially the various version of Basic:

.for a = 1 to 10
blah blah blah
.for b=10 to 100 step 5
blah
.next
.next

These are only two of a whole set of additional commands I created, which I cleverly named DCF+, many of which were to get around the lack of drawing commands (no circles, or diagonal lines back then for the early laser printers), integer only, so I wrote a floating point extension, and a square root command, handy for drawing those circles IBM told me were not possible.

All these commands and extensions were done using just the simple programming commands available, no external utilities, or custom compilations.  So for your amusement, here is my rendition of FOR and NEXT.

.*
.* Code for .FOR Control Word.
.*
.ms on
.dm for on
.if &*1 eq &@forv(&@for)
.then .me
.if &*0 = 5 .then .se *6 = STEP
.then .se *7 = 1
.if &*7 = – .then .se *7 = -1 * &*8
.if &*2 ne = .or &u’&*4 ne TO .or &U’&*6 ne STEP
.then .mg !e!INVALID SYNTAX for .FOR Control Word
.then .me
.if &e’&@for = 0 .then .se @for = 0
.if &e’&@forcc = 0 .then .se @forcc = 0
.se @for = &@for + 1
.se @forcc = &@forcc + 1
.se @forc(&@for) = &@forcc
.se @forv(&@for) = &*1
.se &*1 = &*3
.se @fore(&@for) = &*5
.se @fori(&@for) = &*7
.me …fpt&@forc(&@for)
.dm off
.*
.* Code for .NEXT Control Word.
.*
.ms on
.dm next on
.if &@for = 0 .then .mg !e! Unmatched FOR/NEXT pair.
.then .me
.se &@forv(&@for) = &@fori(&@for) + &&@forv(&@for)
.if &@fori(&@for) gt 0
.and &&@forv(&@for) le &@fore(&@for)
.then .me .goto fpt&@forc(&@for)
.else .if &@fori(&@for) lt 0
.and &&@forv(&@for) ge &@fore(&@for)
.then .me .goto fpt&@forc(&@for)
.else .se @for = &@for – 1
.dm off
.*

Briefly, the parms passed to the command are *0 (the number of  values passed) and *1-*n are the values, so in the third line of the sample above “.for b = 10 to 100 step 5”

*0    7
*1    b
*2    =
*3   10
*4   to
*5   100
*6   step
*7   5

In the macro, variables are resolved when prefixed with ‘&’, so after basic validation and testing for the existence of the variables, arrays are setup for each time the .for is executed, and .next tests, and returns to the dynamically inserted label in the main script/file (Labels are prefixed with three periods ‘…’)

 

For more information on DCF have a look at http://publibfp.dhe.ibm.com/cgi-bin/bookmgr/BOOKS/dsml7m00/CCONTENTS

Earl’s podcasts are:

?NEXT WITHOUT FOR:  http://www.nextwithoutfor.org/

Retrobits:  http://www.retrobits.com/ (general retrocomputing podcast)

Chicken Lips Radio: http://www.chickenlipsradio.org/ (for Commodore computer systems)

and Earl is also a co-host on the Retro Computing Roundtable at http://rcrpodcast.com/

 

Back Top

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.