Everybody into the Boole!

There are three flavors of User Variables in TableMaster: ones with no variety specified (they were the originals), which are integers; Decimal variables, for floating-point numbers; and Text variables, for strings. There is actually a de-facto fourth kind, essentially Boolean variables.

George Boole was a 19th-century mathematician who formulated what came to be known as Boolean algebra, which dealt with variables having values of “true” and “false” rather than numeric values, usually represented as 1 and 0. If that sounds familiar — like the fundamental nature of digital electronics, from your watch to TableMaster — you’re right: it is. Most computer languages have some sort of Boolean variable. Delphi (which is basically Pascal, named for another mathematician) certainly does. And so does TableMaster … sort of.

TableMaster doesn’t have a flavor of variable explicitly called Boolean. What it does have is two commands that can treat any numeric variable as if it were Boolean whether it’s integer or decimal: .IFYES and .IFNO.

These two commands check to see if a variable’s value is 0 or anything other than 0. If it’s 0, that’s considered a “no” — false, in Boolean terms —  while if it’s not 0, that’s considered a “yes” — true. With this, you can use ordinary numeric variables to act as Boolean variables.

…okay, I’ve gotta stop doing this. I just added more to TableMaster.

I was going to explain how you could, by setting a variable to 1 or 0 with .SET {SomeVar} TO 0 or .SET {SomeVar} TO 1, use it for the Boolean commands of .IFYES and .IFNO. But … why make it harder than it needs to be?

So, as of three minutes ago, TableMaster has two new commands:

.YES {SomeVar} sets the value of the variable to 1. Likewise, .NO {SomeVar} sets it to 0.

If you prefer more computer-language-like versions, you can use .TRUE and .FALSE instead, and while I was adding synonyms, I put in .IFTRUE and .IFFALSE as synonyms for .IFYES and .IFNO.

Yeah, new minor version coming. I’ve been accumulating patch notes for what was going to be 1.1.4; looks like it’ll be 1.2.0 instead. Okay, now that I’ve gone and changed the code because of a a blog post, as I was saying ….

You can use numeric (integer or decimal) variables in TableMaster to stand in for Boolean variables. I actually considered adding a specific Boolean type a while back, but decided not to because it would be an unnecessary complication that TableMaster didn’t need, and also because it’s useful sometimes to be able to test whether a variable that you’re using for some other purpose is zero or not. Oh, hell, I’ll add .IFNOTZERO and .IFZERO too, as synonyms for .IFYES and .IFNO, while I’m at it — they might come in handy for making tables more readable.

But continuing with this post, despite interruptions to add features to TableMaster: For example, you’re writing a table to roll up a character’s background and, as part of it, generating how many siblings that character has. It’s important to know if it’s zero (just print “…is an only child”) or non-zero (roll on the tables for birth order, etc.). You can easily test whether your variable {Siblings} is more than 0 with .IFYES/.IFTRUE/.IFNOTZERO and take action accordingly.

There’s a recently-added System Variable that really is a Boolean variable, or at least as close as TableMaster gets: {$Plural}. It’s set by the last number printed, just like {$Last_Number}, and by the .SINGULAR and .PLURAL commands that change the plural-ness that output formatting codes check without actually changing {$Last_Number}. You can use {$Plural} for cases where the output formatting codes don’t include a code to handle some plural you want to use. For example:


There’s no code for the -en ending because it’s a vestige of Old English (the real kind, Anglo-Saxon, which looks more like German than English) which is only used for that one word that I can think of (brother/brethren kind of counts, but the spelling change in the root word makes it impossible to do with just a formatting code; you’d have to do it this way too, and VAXen was never official). So, you need to do what we did back before most of those formatting codes, and make a table (or call it a .MACRO; that’s a synonym) to handle it, like the one above.

There are all kinds of things that you’re likely to be doing when you’re writing tables that involve yes/no decisions. Does this star have habitable planets? Is this house occupied? Is this creature hostile? Using .YES, .NO, .IFYES, and .IFNO makes it easy to handle those.

So, although TBL doesn’t have real Boolean variables in the sense that Delphi/Pascal does, or most other computer languages, it has commands for manipulating and testing them which allow any numeric variable to be treated as a Boolean variable. (and it has more of those than it did this morning!)