19.04.2017 Views

Learn to Program with Small Basic

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

TextWindow.CursorLeft = 4<br />

TextWindow.CursorTop = 1<br />

TextWindow.ForegroundColor = "Blue"<br />

TextWindow.Write("BLUE TEXT")<br />

The cursor<br />

is now here.<br />

Column 0<br />

Column 4<br />

Column 13<br />

Column 21<br />

Row 0<br />

Row 1<br />

B L U E<br />

T E X T<br />

Row 3<br />

R E D<br />

T E X T<br />

Row 5<br />

_<br />

P r e s s a n y k e y t o c o n t i n u e . . .<br />

TextWindow.CursorTop = 3<br />

TextWindow.ForegroundColor = "Red"<br />

TextWindow.CursorLeft = 1 TextWindow.Write("RED TEXT")<br />

TextWindow.CursorTop = 5<br />

TextWindow.BackgroundColor = "Green"<br />

Figure 2-7: Illustrating the output of Properties.sb<br />

Line 2 sets the Title property, which tells <strong>Small</strong> <strong>Basic</strong> the title of the<br />

text window. Line 3 sets the BackgroundColor property <strong>to</strong> "Yellow" for all the<br />

upcoming text outputs. The Clear() method (line 4) tells TextWindow <strong>to</strong> repaint<br />

itself using its BackgroundColor property, which is what makes the window’s<br />

background yellow. Try removing this line from the program <strong>to</strong> see what<br />

changes in your program’s output.<br />

Lines 6–8 set the cursor position <strong>to</strong> column 4, row 1 and set the foreground<br />

color (the text color) <strong>to</strong> blue for the next output. The Write()<br />

method at line 9 writes the string "BLUE TEXT", starting at the current position<br />

of the cursor. The Write() method is just like the WriteLine() method,<br />

except it doesn’t move the cursor <strong>to</strong> the next line after it displays the string.<br />

After this call, the cursor is at column 13 but still in row 1.<br />

Line 11 moves the cursor down <strong>to</strong> row 3. Line 12 sets the foreground<br />

color <strong>to</strong> red, and line 13 calls Write() <strong>to</strong> display the string "RED TEXT".<br />

Lines 15 and 16 move the cursor <strong>to</strong> column 1, row 5; line 17 sets the<br />

background color <strong>to</strong> green. This is the last statement, so the program terminates<br />

at this point (because there’s no more code <strong>to</strong> run). Because the<br />

foreground color of the text window is still set <strong>to</strong> red, the Press any key <strong>to</strong><br />

continue... message is displayed in red on a green background.<br />

Tip<br />

For a complete list of colors you can use in the text window, see http://tiny.cc/<br />

twcolors/.<br />

Getting Started 21

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!