I was trying to print some output text into something resembling columns, but have been having so much difficulty I’m sure I must be blatantly overlooking something; after all, Inform is a program whose sole focus is text, so surely there is a simple way to accomplish what I want.
Let’s look at an example. I have some simple information that I want listed in a column format, and after searching the Inform manual I couldn’t find a discussion of the subject anywhere so I started playing around and wrote the following example. Let’s also stipulate that I’m completely unconcerned that attempting to output text in columns will mean any end-user will experience frustratingly undreadable text while trying to play my game on their iPhone, or using that old 7" CRT monitor they just dug out of their closet, or while resizing the game window to a tiny area occupying 1/45 of the display space on their normal-sized monitor.
[code]The testarea is a room.
Infochecking is an action applying to nothing. Understand “infocheck” as infochecking.
Report infochecking:
say “Value A: [a random number from 1 to 100] Value B: [a random number from 1 to 100][line break]Value C: [a random number from 1 to 200] Value D: [a random number from 1 to 100][line break]Value E: [a random number from 1 to 200] Value F: [a random number from 1 to 100]”;
say paragraph break.[/code]
Although I knew before ever hitting “Go” that the above would be unsatisfactory, for the sake of thoroughness let’s note that the output looks like:
>infocheck
Value A: 66 Value B: 44
Value C: 126 Value D: 26
Value E: 132 Value F: 100
I had an idea that since all the variable output was to be a number of three digits or less, I could “typeset” the output by inserting a variable number of spaces between the statements of each output line if I also switched to fixed-letter spacing. So I got rid of the first code and wrote this:
[code]The testarea is a room.
Infochecking is an action applying to nothing. Understand “infocheck” as infochecking.
Report infochecking:
let valuea be a random number from 1 to 200;
let valueb be a random number from 1 to 200;
let valuec be a random number from 1 to 200;
let valued be a random number from 1 to 200;
let valuee be a random number from 1 to 200;
let valuef be a random number from 1 to 200;
say “[fixed letter spacing]Value A: [valuea][if valuea is less than 10] [otherwise if valuea is less than 100] [otherwise] [end if]Value B: [valueb][line break]Value C: [valuec][if valuec is less than 10] [otherwise if valuec is less than 100] [otherwise] [end if]Value D: [valued][line break]Value E: [valuee][if valuee is less than 10] [otherwise if valuee is less than 100] [otherwise] [end if]Value F: [valuef][variable letter spacing]”;
say paragraph break.[/code]
This results in the following output:
>infocheck
Value A: 141 Value B: 37
Value C: 138 Value D: 140
Value E: 29 Value F: 139
That’s a little better, but still not acceptable to me for three reasons:
a) this whole business of ‘counting the spaces’ seems sort of silly, and
b) I think the fixed-width font (not shown here) used by the Inform test game is fairly ugly; I don’t really want to look at it. Much more importantly (and more seriously), however, is
c) while the ‘count the spaces’ system works for the simple scenario outlined above, it would quickly break down into implausibility in a more complex scenario. For example, how would one ever hope to manually align the following into columns?
[code]The testarea is a room.
Infochecking is an action applying to nothing. Understand “infocheck” as infochecking.
Stuff is a kind of value. The stuffs are cc, ddd, eeee, fffff, gggggg, hhhhhhh, and iiiiiiii.
Report infochecking:
say “Value A: [a random stuff] Value B: [a random stuff][line break]Value C: [a random stuff] Value D: [a random stuff][line break]Value E: [a random stuff] Value F: [a random stuff]”.[/code]
There’s probably a simple technique I’m overlooking here, but since I can’t figure it out any help would be appreciated.