PrintStar's Blog
Ramblings of a Fortran Nut
October 12, 2016 by Jeff

Finally, Some Code!

I’ve been working on my GW-BASIC blog generator quite a bit, and I’ve finally gotten around to posting the code:

The code is currently a set of GW-BASIC source files that each contain a single general purpose.  The goal is to combine all these into a single, functioning static site generator using GW-BASIC’s MERGE command in a programmatic manner.  MERGE will function a bit like the C preprocessor’s #include functionality, but, due to line numbers, you need to plan ahead so that any given file will not overwrite another file.

Below I’ll provide some basic (haha) explanations of each module of the static site generator as it stands today:


This file contains a subroutine for listing files in a given subdirectory.  The task of getting a directory listing as an array is actually pretty infuriating.  In summary, the subroutine actually executes “DIR” using BASIC’s SHELL statement, piping the output to a temporary file.  This file is, in turn, read in and parsed line-by-line in the most naive manner.  Later versions of MS-DOS provided ways to retrieve directory listings without all the other nonsense like file sizes and dates, but MS-DOS 3.10 on a Rainbow 100 does not.


This rather short pair of subroutines create links and lists of links given labels and URLs.


This file contains two subroutines for actually generating complete HTML pages from Textile  markup that are meant to be either a dated post or a static page.  Most of the heavy lifting (e.g. the actual Textile parsing) is handled elsewhere.


This source file contains an extremely simple templating engine (if you could even call it that).  Basically, it’s just a straightforward text replacement engine.  A template filename is provided along with arrays of keys and values, and replaced text is returned.  It can’t do fancy things like loop through lists or perform conditional replacements.  It’s enough, though, to throw a title or link on a page.


This BASIC source code is designed to sort a list of files by either title or date depending on the file’s name.  The idea for blog posts is that each will be named based on the date written: YYYYMMDD.txt In contrast, a page would just be something generic.  If the filename is a date, we need to sort the files based on this date.  If not, the files should probably be sorted based on the page’s title, assumed to be the first occurrence of an h1. tag in the Textile.  This subroutine both sorts the pages appropriately and loads their titles.


This poorly-thought-out file was meant to process a whole directory of Textile into HTML, but it doesn’t have the necessary templates and header/footer code needed that POST.BAS provides.


The madness contained in this file is actually a crude, fragile Textile markup processor.  It unbelievably does work.  Currently, it understands:

  • Headers
  • Paragraphs
  • Ordered and Unordered Lists
  • Links
  • Images
  • Block quotes (because they’re easy)
  • Preformatted text
  • Text styling (bold and italics)

The fact that any of it works is quite baffling to me.  It’s handling of lists, for example, is atrocious.  However, it does actually work, so I can’t complain that much.

The next step is to build an example site to start integrating and testing.  Once that seems to be working, I’ll get an actual blog post or two written in it and attempt to configure the actual Rainbow as a host!


  •   •   •   •   •

Comments are closed.