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

Forgetting How BASIC Works

I finally had enough code earlier today to actually launch the site generator today!  There were plenty of bugs, of course, but I didn’t forsee the bugs related to my handling of arrays.

The first, simple bug I ran into was the “Duplicate Definition” error.  Without really thinking, I never accounted for multiple calls to subroutines that contained BASIC’s DIM instruction for sizing an array.  One cannot simply call DIM for the same variable multiple times.  I do recall a REDIM instruction that existed in PowerBASIC, but it doesn’t exist in ol’ GW.  To fix the issue, I basically “check” if I’ve called the subroutine before by seeing if a variable is set to 1.  If so, I use the ERASE statement to clear the arrays that I’m about to dimension.  It’s dirty but functional.

Once that simple bug was fixed, I noticed most of my arrays were empty later on in the program.  After some digging, I realized that my naive use of assignment of arrays to another variable simply doesn’t work.  I had to squeeze in some additional dimensioning and assignment loops to copy arrays, as one can see in this diff of the blog generator master routine. I feel silly for making such a mistake.

There are still a number of bugs, and it doesn’t “just work” yet, but it did actually generate two HTML files the last time I ran it.  The files themselves, though, are a mess, meaning I’ll need to look at how the Textile processor is wokring again.  Additionally, I did run a test that I thought had shown I could just issue a new line character, but that test was clearly incorrect.

  •   •   •   •   •

Comments are closed.