-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsimple08.html
More file actions
105 lines (93 loc) · 2.46 KB
/
simple08.html
File metadata and controls
105 lines (93 loc) · 2.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
---
layout: base.html
title: Simple HTML - Fun with PRINT
---
<section class="side-by-side">
<canvas class="game right" id="canvas" oncontextmenu="event.preventDefault()"></canvas>
<div>
<article>
<h1>Fun with PRINT</h1>
<pre>
NEW
10 CLS
20 PRINT TAB(5); "I AM GREAT"
30 PRINT TAB(8); "BUT SLIMY SID"
40 PRINT TAB(12); "IS SNEAKY"
RUN
</pre>
<aside>
The command <code class="command">PRINT TAB</code> tells the computer to leave some spaces before a word or number on the screen.
</aside>
<h2>PRINT TAB program</h2>
<pre>
NEW
10 CLS
20 PRINT "HOW MANY SPACES"
30 PRINT "DO YOU WANT TO LEAVE?"
40 INPUT N
50 PRINT TAB(N); "HELLO"
RUN
</pre>
<p>In this program you tell the computer how many spaces to leave before the word HELLO. The computer stores the number in the variable <code>N</code>,
and then uses <code>N</code> with the <code class="command">PRINT TAB</code> command.</p>
<p>Note that <code>TAB</code> actually starts counting at 1 so <code>TAB(1)</code> starts at the beginning of the line, and you need to use <code>TAB(2)</code> to start with a space.
Try running the program above multiple times to see this.</p>
<h2>Leaving empty lines</h2>
<pre>
NEW
10 CLS
20 PRINT "HELLO"
30 PRINT
40 PRINT
50 PRINT
60 PRINT "GOODBYE"
RUN
</pre>
<p>To make the computer leave
empty lines on the screen
you use PRINT by itself.
This program makes the
computer leave three
empty lines between the
two messages.</p>
<h2>Birthday program puzzle</h2>
<p>This program displays a birthday
message. Before you run it, you
must put the numbers in the
brackets after the <code class="command">PRINT TAB</code>
commands. Experiment with different
numbers to see if you can put the message in
the middle of the screen.</p>
<pre>
NEW
10 CLS
20 PRINT:PRINT:PRINT
30 PRINT:PRINT:PRINT
40 PRINT TAB(??); "HAPPY BIRTHDAY"
50 PRINT TAB(??); "TO YOU"
60 PRINT TAB(??); "*****"
RUN
</pre>
<aside>This program uses colons <code>:</code> to put several commands on one line. You can always put several commands on one line if you separate them with colons.</aside>
<h2>Making columns</h2>
<pre>
NEW
10 CLS
20 PRINT:PRINT:PRINT
30 PRINT "DAY", "MY LUNCH"
40 PRINT
50 PRINT "MONDAY", "CHOCOLATE"
60 PRINT "TUESDAY", "HAMBURGERS"
70 PRINT "WEDNESDAY" "ICECREAM"
80 PRINT "THURSDAY", "SAUSAGES"
90 PRINT "FRIDAY", "LOLLIPOPS"
100 PRINT "SATURDAY", "CHIPS"
110 PRINT "SUNDAY" "POPCORN"
RUN
</pre>
<footer>
<a href="{{ base_uri }}/simple09" class="button">Next</a>
</footer>
</article>
</div>
</section>