text
stringlengths
0
897
{i:"`text.delimeter`;`print`"}
The last text property to consider is `text.delimiter`. This is a special string that is added to the console after every `print` statement. Try this:
```terminal
]print 1; print 2; print 3
1
2
3
```
We're just putting three `print` statements on one line, joining them with semicolons. You can see that each number appears on its own line. But now enter `text.delimiter="*"`, and then repeat the previous command. (Remember to user the up-arrow key to save yourself some typing!)
```terminal
]text.delimiter="*"
]print 1; print 2; print 3
1*2*3*
```
The difference this time is that all the output appears on one line, but after each number is an asterisk (the value you assigned to `text.delimiter`). To restore the standard behavior, do `text.delimiter=char(13)`. To understand that, first recall that the `char` intrinsic function returns a character (string) defin...
{i:"line break"}
`char(13)`, in particular, is a line break. It causes the text cursor to go to the column 0 of the next line. If the cursor was already on row 0, then it scrolls the whole text display up (i.e. moves everything up by one line), and then puts the cursor at the start of row 0.
D> There are a couple other useful control characters, and a whole host of character codes that produce special glyphs in Mini Micro. To learn these, run `/sys/demo/specialChars.ms`.
Changing `text.delimiter` to the empty string (that is, `""`) is handy when you need to print something, do some extended calculations, and then print something else, all on the same line. It's even more handy when you want to print something on row 0 without scrolling the screen.
That covers all the `text` properties. As for the functions, `text.clear` does almost the same thing as the `clear` method you already know, though it applies only to the text display (and not to the graphical displays you'll learn about soon). The other text functions all have to do with getting or setting the data ...
|Data|How to get it|How to change it|
|----|-------------|----------------|
|the text character displayed|`text.cell`|`text.setCell`|
|the text color|`text.cellColor`|`text.setCellColor`|
|the background color|`text.cellBackColor`|`text.setCellBackColor`|
You use all these methods with parameters that specify the column and row of interest. For example, try this:
```terminal
]clear
]print "Neat?"
Neat!
]print text.cell(4, 24)
?
]text.setCell 4, 24, "!"
```
In this way, you can read or set the contents (or colors) of any cell on the screen. Many classic games, like *Rogue* and *Dwarf Fortress*, use exactly this sort of technique to draw 2D games using only a text display. In Mini Micro, the need for this is reduced, since it has powerful graphics capabilities you'll lea...
## ASCII Bear
{i:"ASCII art"}
To celebrate your new understanding of the text displays and color, here's a program that creates an adorable little bear using "ASCII art" (artwork made only with standard letters, numbers, and punctuation). Type carefully!
```miniscript
text.color = color.black
text.backColor = color.white
clear
print " _ _"
print " (c).-.(c)"
print " / ._. \"
print " __\( Y )/__"
print " (_.-/'-'\-._)"
print " || x ||"
print " _.' `-' '._"
print " (.-./`-~\.-.)"
print " `-' `-'"
text.setCellColor 7, 20, color.gray // belly button
text.setCellColor 6, 23, color.blue // left eye
text.setCellColor 8, 23, color.blue // right eye
```
Feel free to tweak this and improve it if you can!
## Exploring the Demos
{i:"`/sys/demo`,`theMatrix`;`/sys/demo`,`forestFire`"}
There are several demos in `/sys/demo/` that you are better equipped to understand now. `theMatrix.ms` demonstrates direct manipulation of the text display. The logic for managing all those dropping columns of characters is a little complex, but see if you can find where the characters and colors are poked onto the s...
{i:"`/sys/demo`,`typing`"}
There's a typing game called `typing.ms` that also uses the text display. Right near the top of the program, you'll find a `printAt` function that uses the things you learned today to print things exactly where they should appear on screen.
{i:"`/sys/demo`,`therapist`;`/sys/demo`,`textAdventure`;`/sys/demo`,`acey-deucey`"}
Finally, several of the other demos are primarily text-based, but don't do anything too fancy with the display. The `therapist`, `textAdventure`, and `acey-deucey` programs all fall into this category.
A> **Chapter Review**
A> - You learned how to represent colors in Mini Micro using HTML color syntax.
A> - You found the `color` module with 20 built-in colors, plus several handy functions.
A> - You explored the `text` module, and its several properties and methods that let you display (or read) text anywhere on the screen, in any colors you like.
{chapterHead: "Day 18: Pixel Graphics", startingPageNum:213}
{width: "50%"}
![](Chapter18.svg)
Q> The future belongs to those who believe in the beauty of their dreams.
Q>— Eleanor Roosevelt (First Lady and activist, 1884-1962)