Public Domain C Utilities

(First Series, Aug 1, 2001)

 I. Todd-Draw, a ASCII character picture editor

II. The HTML Linker Program

 III. Other Programs

 IV. Papers Bearing on Computers and Cognitive Studies

All programs herein described are in the public domain, and may be used for any purpose whatsoever, without permission or notification, but they are offered "as-is" without any warrantee, express or implied.

                                   Andrew D. Todd
                                   1249 Pineview Dr., Apt 4
                                   Morgantown, WV 26505




(what follows was written in 1993-94. V. 1.078 is functional if crude, V. 1.085 was never completed-- too much pressure of other work. The code is included to provide models for modifications)

Todd-Draw is a very simple graphics program for people who want to use graphics in firm subordination to prose. If you want to make pretty pictures, it's not for you. But if you want to use a simple picture sometimes, to explain something that defies being put into words, it may be helpful.

There's nothing here that you couldn't do inside your favorite word processor, given sufficient patience and determination, but the thing is that a word processor thinks of text in terms of lines of words. Even when you disable word wrap, it won't give you the tools for picture making.

Todd-Draw will. That's what it's meant for.

I assume you are not interested in trading in your word processor for a desktop publishing program, and I do not expect you to spring for either a VGA or a laser printer. Todd-Draw creates pictures out of ASCII characters, by which I mean the printable characters defined in the ANSI standard, and carriage return and line feed. They are stored as lines of text in a file, just like a text editor. So it's easy enough to read them into a standard word processing document. The beauty of sticking with ASCII characters is that one can make a come-as-you-are graphics program. Another advantage is that you can convert your document, with pictures included, to ASCII, for uploading to a bulletin board, E-Mail, or whatever. Try doing that with a desktop publishing file. Someday, there may be a general standard for graphics-- or the equipment may become fast enough and cheap enough to go FAX. But that time is not yet. So I've made something to do for the meantime. For this, you won't even need a mouse.

You'll use the number pad instead. the arrow keys mean the obvious things, but the Home, End, Page Up, and Page Down keys move the cursor diagonally. So you can go in eight directions instead of four.

You can choose to draw a line, made up of '-', '|', '\', and '/'s, or you can brush in any desired character.

You can mark out a block, and move, copy, or delete it, the way you can in a word processor.

You can edit two pictures, or canvases (I beg your pardon for the smugness of the word), at the same time, and move and copy material between them.

You are probably going to want to put in a little text, labels and such, so I've provided a text editor mode. When you enter a character, the left margin will set itself. You can type away in in something like a word processor's overwrite or non-insert mode. When you hit the carriage return, that will set the right margin, and as long as you keep typing text only, it will be wrapped within those bounds. You can use the tab key to set a new left margin. When you move with the cursor keys, or bring up the menu, the margins will clear themselves. It's not much of a text editor, but it's good enough for labels.

You mark the block by switching to block-mark mode and painting it out with highlighting. Since this could be tedious, I provide an easier way: draw the outline of the block, move the cursor inside it, then use the ENCLOSE function, which will fill the region inside with highlighting.

Once you've done that, mark the 'pivot point.' When you move or copy, this point will be lined up with the cursor.

The insert key has the meaning: pen up--pen down. You toggle it up if you want to move without leaving a trail behind you.

The delete key is also a toggle. It switches on and off the Wipe mode. Wipe mode, in effect, reverses whatever cursor movement does at the moment. If you are drawing a line or brush stroke, it will erase it. But if you are marking out the block, it will unmark that spot.

All the modes are indicated on the status line.

You can print the canvas out on just about any printer, either from within Todd-Draw, or just by printing the file after You've saved it. It's just an ordinary text file, after all.

All you need to run Todd-Draw is a reasonably true clone, with 256K of memory. I developed the first version on a Sanyo 555.

I regret that due to prior commitments, I cannot support Todd-Draw. However, since it's free, I don't feel under an obligation to do so. Bugs reported will be dealt with as time permits.

I include the source code in the distribution, and declare Todd-Draw to be in the public domain. Anyone who wants to have a go at porting it to any other environment, or building it into a word processor or other larger program is welcome to. Just so that you make appropriate acknowledgments of the kind that would be expected in a scientific journal. Cite my name in the source code if that's public, or in the startup screen or manual, if it isn't. And make it clear that my code is public domain, even though your adaptation of it may not be. If possible, indicate where you got my code, or where it may be obtained. These restrictions have no legal force incidentally. They are purely a matter of honor.


The Libraries:

Apart from TODD-DRAW itself, the libraries are of value. In order to create TODD-DRAW, I had to develop a library of fairly general purpose functions, which can be reused for other programs.

// this section applies only to v. 1.085 //

Most importantly, there is a point and shoot file selection module, broadly similar to the Macintosh system's 'SFGetFile' and 'SFPutFile' toolbox routines. This routine makes it easy, with very little work, to prompt the user for a file in as user- friendly a way as the major commercial applications programs. It is in advance of maybe 90% of shareware products.

There is also a point and shoot menu routine, of which I make no particular boast. It is adequate, but not spectacular.

Both of these use a third function, 'get_mov_ch.' This obtains input from both the keyboard and the mouse, and resolves them into characters and character resolution moves. You supply a function to specify which keys indicate moves in which direction, so you can impose a comparatively uniform look and feel over the whole of your program.

// end of section //

There are a series of extensions to the Mix libraries (which already include System V, plus supersets of Microsoft C 4.0 and Turbo C 1.0). My additional extensions include some string handling, some disk and directory checking, some min-max functions, and some additional video BIOS bindings.

If you haven't got MIX Power C, don't expect any sympathy from me. It is so cheap that if you can afford any other compiler, the price of Power C is small change. Their current price is only about $30.00 plus shipping for the compiler and library source code, and that includes a bloody thick book. $20.00 more gets you a symbolic debugger. So if you are using some other compiler which does not have the same functions, you can easily get them from the Power C library source code. They are royalty-free, incidentally.

Their address is:

MIX Software
1132 Commerce Dr.
Richardson TX 75081

As for my code, it is, as I have said, public domain. You may have to port it to conform with whatever system of screen management you use.

List of files for Todd-Draw:

TDDR_78.C,Todd-Draw 1.078, complete code   tddr_78.c

TDDR_85T.TXT,list of functions used, 6-27-92    tddr_85t.txt

TDDR_85.C,Todd-Draw 1.085, main module      tddr_85.c

TDDR_85C.C,ditto, chararray library                  tddr_85c.c

TDDR_85F.C,ditto, file selector, incomplete        tddr_85f.c

TDDR_85L.C,ditto, assorted library functions      tddr_85l.c

TDDR_85M.C,ditto, menu selector, incomplete     tddr_85m.c

TDDR_85K.H,ditto, names for keycodes               tddr_85k.h

TDDR_78.TXT,documentations for Todd-Draw 1.078   tddr_78.txt

The HTML Linker (2004):

This is a tool to simplify publishing books of many chapters on a website. This program was used to create the links in most of the books posted elsewhere on this website. Doing the same thing for three hundred chapters or so naturally got rather tedious. That worked out to a couple of thousand links, and the possibilities of error were legion. So I started by making HTML stubs, inserting them, and patching them. But eventually, I went on to build a full linker program.

The Main HTML Linker Program  htm_link.c

The Ancillary Directory Listing Program   htm_list.c

Other Programs:


This is a crude little program to convert EBDIC into ASCII. A legacy of disentangling my E-mail and internet access from the toils of an IBM 370 mainframe.



The Nutcracker Program

(with apologies to Clara)

This program is designed to convert sizable files containing a mixture of sections of ASCII characters and sections of something else into readable form. It converts all nonprintable bytes into mnemonic or hexadecimal form. The user can then use the search/replace functions of a word processor to convert the files into the desired final form.

Unlike the standard "strings.c" program, nutcracker is not primarily geared to finding text within machine-language programs, but to converting data files which are in proprietary formats. It incorporates non-printable bytes in expanded form in their proper place within the output, on the assumption that the user is going to want to convert these bytes into something else-- perhaps an aliased character, or perhaps a page markup tag. The assumption is that you will be using it on a file which is about ninety-five percent printable ASCII characters, but with a remaining five percent which causes conventional file conversion or file reader programs to crash.

This program is a blunt instrument, and somewhat laborious to use, but its great virtue is that, provided the characters are in ASCII, and have not been compressed, the program WILL NEVER FAIL. I wrote it originally when I was trying to get an old-fashioned word processor, Wordstar 5, to work with a new printer, and needed to do a bit of reverse engineering. I have used Nutcracker to read Word and WordPerfect files, and practically, I should think the only significant limitation is that it won't handle files which have been compressed (eg. Acrobat).



This is a variant form of the Nutcracker Program, tuned to do a somewhat more efficient job on Word files, by deleting x00 and xFF (apparently used as padding characters), and converting x92, x93, x94 (smart quotation marks) to dumb quotation marks. Microsoft has apparently adopted a policy of continually changing the file format to interfere with compatible programs, as described in the the Findings of Fact, with the result that sophisticated conversion programs may be useless if the Word document was generated by a comparatively recent version of word.




Programs to convert back and forth between Wordstar and HTML. These programs only convert back and forth between HTML and Wordstar 3/4. However, more advanced versions of Wordstar can convert down to this format, thus linking up with my programs, and if you go about it the right way, you can set up scripts to do the whole job with one command.



There is an englishman who has written a program to handle Wordstar 7 directly, but he has apparently not seen fit to publish his source code.

The Early English Population Simulation Model (2000)

(Work in Progress)

This is a demographic model, in the process of being  built, together with a progress report written at the time I put it aside. The completed sections would lend themselves to a wide range of population modeling, and could provide a starting point if someone else wanted to do a project without having to start from the beginning.



Papers Bearing on Cognitive Studies

           Andrew  Todd  and William Todd

"Notes  towards  a  Semantic Simulation  of  a Fragment of Child Language" (1987)

An Example of Prior Art in Statistical Semantics and Artificial Intelligence Systems.


(by kind permission of the Ohio State University)

Andrew D. Todd



       Andrew D. Todd

  Software Piracy and the Crisis of Capitalism (1993)