The Boston Diaries' Journal
 
[Most Recent Entries] [Calendar View] [Friends View]

Thursday, September 28th, 2023

    Time Event
    5:51a
    A classic blunder, like getting involved in a land war in Asia

    The first time I included some BASIC code, I typed in the sample directly from a magazine (like we used to do back in the 1980s). The second (and most recent) time I included BASIC code, it was extracted from a disk image downloaded from the Intarwebs (using code I wrote) and then decoded into ASCII, using code I wrote, based off a text file I also found on the Intarwebs. I didn't notice when I posted the code because it was a wall of text 32 characters wide (the width of the text screen on a Color Computer). It was only months later when I finally noticed all the THENNOTs littering the code.

    There was nothing wrong with the actual file, but I did locate the bug in my code:

    char const *const c_tokens[] =
    {
      "FOR",
      "GO",
      /* ... */
      "SUB",
      "THEN"
      "NOT",
      "STEP",
      "OFF",
      /* ... */
      "DSKO$",
      "DOS"
    };
    

    If you look close, you'll see there's a missing comma after the THEN token, and in C, two literal strings separated by whitespace are concatenated into a single string. Thus, all the THENNOTs I was seeing. And a bunch of incorrect code because most of the BASIC keywords were then off-by-one (a classic mistake of C programming).

    << Previous Day 2023/09/28
    [Calendar]
    Next Day >>

The Boston Diaries   About InsaneJournal