Back in the early 1990’s when I was programming professionally for a living, I was always tinkering around with little utility programs to help myself. One area of interest was enhancing batch file screen formatting abilities. I wanted to see menu screens with color and boxes, etc. While there were programs you could buy to do this, I never wanted to buy one because none worked exactly like I wanted them to though some were very close. And why buy something when I could write it myself. So that’s just what I did, it was small, used no memory, and worked well. In the years that passed, over time I lost all the source code for it, and everything else I ever wrote, most likely by deletion thinking I didn’t need it anymore. Whats a hard copy? 😀 Fast forward many years, and I find myself wishing I still had it.
First, a little backstory that led to this project.
I first learned relational databases with Ashton Tate dBase III+. I then migrated to FoxPro when it came out. The natural progression was then to Clipper. I programmed in Clipper for many years starting with the Summer 87 version and ending with the 5.2 version. Since late 2018 I’ve been re-learning Clipper 5 and the language additions version 5.3 brought, and have written a few programs that I use regularly now. Clipper is a fun language to program in! I’ll be detailing at least one of them in a series of future posts. Since Clipper is a DOS based programming language I naturally use a DOS virtual machine. I’ve also been learning the later versions of FoxPro (not the Windows versions). All of these need different DOS environments setup (include paths, binary paths, library paths, environment variables, etc). Because of that I setup a crude text based menu asking which environment to setup when I start the DOS virtual machine. Example:
I’ve been using this crude menu for a long time now and each time I see it I get disappointed. I toyed around with making this nicer using WordPerfect Office, which I used at one of my employers in the past. I also tried several menuing programs. None work like I want them to. Recalling what my former A-Batch helper did and wishing I still had it, I set out to re-create it. I have now completed it after just a few evenings of work.
The original version was written in Microsoft C, which I no longer have access to, nor do I own a copy. I do own a copy of Borlands Turbo C, one of the first C compilers I bought for DOS. I used Mark Williams C on the Atari ST prior, and some version on the Apple Macintosh in college. I’ve slept a few times since I last programmed in C, but still remember much of it. I thought recreating A-Batch would be a great opportunity to brush those skills off. Since I own a copy of Turbo C, that’s what I set out to do it in.
Now the backstory is out of the way, lets get into the project. This post will detail what A-Batch is designed to do, how I plan on using it, and it’s features. The next one will feature the source.
I designed A-Batch as a DOS batch file helper. It’s primary purpose is to output screen elements with different colors. To that end there are a few primitives A-Batch provides:
- Cursor Positioning
- Boxes
- Text
I purposely did not design it as a script/file command interpreter. In other words I don’t want it to read from a file and process all the lines like an interpreted language. I want it to process one command and exit, returning control back to the batch file. This approach is not as fast as being fully interpreted, but works for my needs in the simplest form possible. With this approach I can call A-Batch as needed during the batch file execution lifetime. With the original version, I had constructed some elaborate multi-screen menus. Here is an example of the same menu as above, but using my new version of A-Batch to make it more elegant:
Much nicer!
The overall usage will be to call A-Batch several times to draw a menu presentation screen. Example: draw a box, display some text or a box title, then display some more text, all with custom colors and styling elements (borders) where applicable.
I came up with a short list of commands I remember the original A-Batch having:
- goto x,y
- draw box
- show text
- set background
From there, I settled on the actual command names A-Batch will recognize, and added some additional commands:
- back = draw background by filling screen using given characters in given color
- box = draw box at x,y with given width, height using given style in given color
- cls = clear screen
- goxy = move cursor to x,y coordinate
- help = display help/syntax
- text = display text at x,y in given color
- title = display box title at x,y with given ornamentation characters in given color
- version = display program version information
- wait = pause execution for given number of seconds
Once I had the command list defined (minus help and version), I defined the syntax for each, with each parameter being required. If a parameter is not present, the command is not executed:
back style fc bc
- style is the background style passed as a string of 3 characters (left, middle, right). One character would do, but I implemented it using some of the same constructs used by the box routine, thus the left and right characters are used for the left and right sides (column 1 and 80 respectively). I may re-address this implementation later, but it works for now. The default style is “back” which is a string of character 176.
- fc is the foreground color. Supported values are: black, blue, green, cyan, red, magenta, brown, lgray, dgray, lblue, lgreen, lcyan, lred, lmagenta, yellow, and white. *
- bc is the background color. Supported values are: black, blue, green, cyan, red, magenta, brown, lgray, dgray, lblue, lgreen, lcyan, lred, lmagenta, yellow, and white. *
box x y w h style fc bc
- x is the column for the left side of the box. Expressed from 1 to 80.
- y is the row for the top of the box. Expressed from 1 to 25.
- w is the width of the box. Not the end column, the actual width! Expressed as a number.
- h is the height of the box. Not the bottom row, the actual height! Expressed as a number.
- style is the border style passed as a string of 10 characters, using same syntax as Clipper (top left, top middle, top right, middle left, bottom right, bottom middle, bottom left, middle right, middle middle, filler). Supported values are predefined with options of:
- single = single line border all around with, space as filler
- double = double line border all around, with space as filler
- block = full block border all around, with space as filler
- fat = half block border all around, with space as filler
- sd = single line border on top and bottom, double line border on left and right, with space as filler
- ds = double line border on top and bottom, single line border on left and right, with space as filler
- none = space as border all around, with space as filler
- fc is the foreground color. Supported values are: black, blue, green, cyan, red, magenta, brown, lgray, dgray, lblue, lgreen, lcyan, lred, lmagenta, yellow, and white. *
- bc is the background color. Supported values are: black, blue, green, cyan, red, magenta, brown, lgray, dgray, lblue, lgreen, lcyan, lred, lmagenta, yellow, and white. *
cls
No parameters. It just clears the screen. Not really needed since the DOS “cls” command does the same thing. It was an easy first command to implement to test the parser.
goxy x y
- x is the column to move the cursor to. Expressed as a number from 1 to 80.
- y is the row to move the cursor to. Expressed as a number from 1 to 25.
help
No parameters. It just displays the usage syntax. This is also presented if no parameters are passed to A-Batch.
text x y “text” fc bc
- x is the column to display the text at. Expressed as a number from 1 to 80.
- y is the row to display the text on. Expressed as a number from 1 to 25.
- “text” is the text to display. If there are spaces it should be enclosed in double quotes.
- fc is the foreground color. Supported values are: black, blue, green, cyan, red, magenta, brown, lgray, dgray, lblue, lgreen, lcyan, lred, lmagenta, yellow, and white. *
- bc is the background color. Supported values are: black, blue, green, cyan, red, magenta, brown, lgray, dgray, lblue, lgreen, lcyan, lred, lmagenta, yellow, and white. *
title x y “text” fct bct style fco bco
This command will automatically add a space before and after the title text to separate it from the surrounding ornaments. I may rethink this later.
- x is the column to display the title text at. Expressed as a number from 1 to 80.
- y is the row to display the title text on. Expressed as a number from 1 to 25.
- “text” is the title text to display. If there are spaces it should be enclosed in double quotes.
- fct is the foreground color of the title text. Supported values are: black, blue, green, cyan, red, magenta, brown, lgray, dgray, lblue, lgreen, lcyan, lred, lmagenta, yellow, and white. *
- bct is the background color of the title text. Supported values are: black, blue, green, cyan, red, magenta, brown, lgray, dgray, lblue, lgreen, lcyan, lred, lmagenta, yellow, and white. *
- style is the border style passed as a string of 10 characters, using same syntax as Clipper (top left, top middle, top right, middle left, bottom right, bottom middle, bottom left, middle right, middle middle, filler). Supported values are predefined with options of:
- single = single line border all around with, space as filler
- double = double line border all around, with space as filler
- block = full block border all around, with space as filler
- fat = half block border all around, with space as filler
- sd = single line border on top and bottom, double line border on left and right, with space as filler
- ds = double line border on top and bottom, single line border on left and right, with space as filler
- none = space as border all around, with space as filler
- fco is the foreground color of the title ornaments. Supported values are: black, blue, green, cyan, red, magenta, brown, lgray, dgray, lblue, lgreen, lcyan, lred, lmagenta, yellow, and white. *
- bco is the background color of the title ornaments. Supported values are: black, blue, green, cyan, red, magenta, brown, lgray, dgray, lblue, lgreen, lcyan, lred, lmagenta, yellow, and white. *
version
No parameters. It just displays the program version information.
wait n
- n is the number of seconds to delay
* For colors, “blink” is also valid, but not yet implemented.
One thing I will be adding is some auto-centering by means of specific passed values to trigger the ability. Another feature I will add is a get key routine, which will disable the cursor, get a key from a valid list without echo, then re-enable the cursor, and return the value back as an error code so it can be tested in the batch file. Once these are in place I will have completely recreated the original A-Batch. I may have uploaded the original to CompuServe or some BBS’s at some point. If you stumble on this post and have a copy of my original non-commercial A-Batch, please forward it to me.
In its current form there isn’t any sanity checking on the parameters passed to the commands. You can overwrite the screen boundaries, supply invalid coordinates, etc. I may add some of these checks later. For now I’m not worried about it since this is primary for me to use.
In the next post I will present the source code and walk through it.