You are on page 1of 8

Chapter 2 The Print Command

I I. piiii fill !Mm

m SSKm M
B H B B P H &

mm

H !-:!"'": !IM '!'V* ! ' !

i l

! ! IH H IH l

itH R w ^ m w ii'^ M M M
-.S^rfc^-.^-vrf/i v !fv:'j,:.-..v u -;<:>* w . .v ir

V :-^iys'^ * v - & ^ ? - ^ * a 6fcvSlfc!

WjJS

!/W - !;.:.;:J! !' -v V^'>; ^v^:- -V ! ''; -^mi:,: S-m.---.m^c ! -; !" -: ! .i : ,! :V O ; !


H il

*' * r

8^sfuK ap^>^a ! - !B'-E ! F aJe^ ay*1 jolaiB ^ " w skSjs$M w &j wSBm 0S& 00M I ya jP gB ft#
I lf lM iis ^ p s i# :.J |g v la *,1'#!it~iv&yjr ^.*c.

! p| & Ks @

#?e;i

H |fl & W iw

B l B l ?".^n-5-^'. ;:

Pte4v ^grS

O *-si;ii:< i?^ iiS - ?'?

m
9 !
m

tel
SPM h I 1B i i U II i p w Wa B i, i

81a

Si SHS SS dtB
*

! !

-! :>i;, . mm. r;.m $ k. -S I ji?.va;

Chapter 2

The Print Command


A good way to start is to jump right in and swim! Type the following:
PRINT [HELLO THERE]
To type [ press the S H IF T key and at the same time type N. To type ] press the s h i f t key and at the same time type M.

M jL C M E TO LOGO t M0 T
k

R0S HOM TO HELLO

W lH ? CHELLO THERE]

The instruction appears on the screen, but is not obeyed until you press the r e t u r n key. Logo will then respond
HELLO THERE

Suppose you wanted Logo to print another mes sage like


I AM T H E GREATEST

but you made a mistake and typed


PRINT [I AM T H E R E ]
r e t u r n

Okay, hold on, do not press the

key.

Press the - key for each character you want to erase until the screen shows
PRINT [I AM T H E

Now type the rest of the line.


PRINT [I AM T H E GREATEST]

Press
I

r e t u r n

and your instruction is obeyed.

AM T H E

GREATEST

HELLO THERE] T AH THE GREATEST]*

OO G
HOM TO HELLO

The - key is one of several editing actions Logo provides so that you can change what you have typed without having to type the entire instruc tion over again. You will be introduced to more editing keys in later sections of this Guide.

You can have Logo print some other sentences by typing p r i n t and enveloping what you want typed in brackets as illustrated in the previous example. Clearing off the Screen A useful command is c l e a r t e x t . It clears the screen of text and starts the text at the top of the screen.
CLEARTEXT
Press the
RETURN

CONE TO LOGO OHM KNOB HOW TO HELLO OPPEQ! INT CHELLO THERE] 0 THERE NT C l AH THE GREATEST] THE GREATEST

key.

The screen clears and the I (cursor) appears at the top of the text screen.
DR T KHOU HON TO HELLO OPPEQ! INT CHELLO THERE] ELLO THERE PRINT t C il a h t h e GREATEST] ^ i h t c AH THE GREATEST AH THE fift-----c l ear t ext !

Writing Programs You can make up new commands in Logo by de fining procedures. You can use the command t o to signal your intention to Logo. On the same line you tell Logo what name the procedure will go by. Then, you tell Logo what you want the procedure to do. For example, le ts define a procedure, g r e e t , so that whenever you type g r e e t Logo will type
HI BY THERE NOW

Type t o followed by the name of the procedure to start defining the procedure.
TO G R E E T
Type a space to separate the words TO and G R E E T . Press the
r e t u r n

key.

Logo now uses > instead of ? as the prompt sym bol. This is to remind you that you are defining a procedure and not entering instructions to be car ried out right away.

PRINT [HI THERE] P R I N T [ B Y NOW] END

Press the r e t instruction.

u r n

key after each

The word e n d signals t o that you have finished the procedure definition. Logo will now type
GREET ? DEFINED

Logo again uses ? as the prompt symbol. Run the procedure by typing
GREET
Press the
r e t u r n

key.

Logo types
HI BY THERE NOW

Bug Box Suppose g r e e t does not work. Perhaps you typed something strange. Soon you will learn how to edit your procedure, that is, change the parts you dont like. In the meantime, just try writing another procedure. Give it another name; lets say g r e e t i . (Note that numbers can be used as char acters in Logo commands.)
TO G R E E T 1 PRINT [HI THERE] P R I N T [ B Y NOW] END
Type a space between
TO

and

GREET1Press the
R ETU R N

key.

15

Run this procedure by typing


GREET1

Logo should type


HI BY THERE NOW

You can use the command r e p e a t to run g r e e t over and over. For example you could have r e p e a t run g r e e t five times.
REPEAT 5 [GREET]
Type a space between and 5. Press the
r e t u r n r e pe a t

key.

a s i

OEFIMEO

If you have a g r e e t i procedure, you can use it instead of G R E E T.

" r epea t

5 CG R EETJB

Logo responds
HI T H E R E BY NOW HI T H E R E BY NOW HI T H E R E BY NOW HI T H E R E BY NOW HI T H E R E BY NOW

BY j j * S REPEAT 5 CGREET3 HI THERE BY NON HI THERE BY NON HI THERE BY NON HI THERE BY HOM H I THERE BY HOM

You could have times.


REPEAT 1000

r e pe a t

run

g r e e t

a thousand

[GREET]

If you want to stop this process type

CTRL-G.

16

Bug Box If c t r l - g doesnt stop Logo from printing on the screen, make sure you are typing the key combi nation correctly. While holding down the C t r l key press G. Otherwise you can wait until r e p e a t is finished. A Note In the next chapters of this Guide we will not al ways remind you to press the r e t u r n key or to type a space between words. Logo Vocabulary Here is a list of Logo words you have used.
P R IN T CLEA R TEX T TO END R E PEA T

We have also used several special keys.


R ETU RN
<

CTRL-G
[ ]

space bar

You might also like