A subprogram is a named sequence of steps for another program to execute. page 5Ĩ Drawings made using repeat or repeat ] page 6ĩ page 7 PROGRAMMING FUNDAMENTAL 3: Subprograms For convenience and concision, we can add a new command to Logo's language. In between the drawings, I picked up the pen and moved the turtle. The burst shape at the center used the penup and pown commands. (This is called nesting.) What does this do? Think about it, then try it: repeat 4 rt 90] How about this? How is it different? repeat 8 rt 45]ħ All of these drawings use the repeat command. The general form is: repeat number We must use the keyword repeat followed by a number and then a sequence of commands in. We tell Logo, for example: repeat 4 or repeat 4 to save ourselves some typing in making a square. Just about every programming system has a way of doing this repetition, or iteration, as computer scientists call it. Many of the things that computer programs do, they do over and over. (And that's all it will do.) Can you draw these?ĥ page 3 BASICALLY HANDY clearscreen or cs erases all drawings and sets turtle at center useful at *beginning* of multi-step commands! penup or pu pick pen up, so you can move turtle without leaving tracks pown or pd put pen down hideturtle or ht hides the turtle so you can admire your drawing showturtle or st shows the turtle so you can see what you're doing setpensize makes pen larger, easier to see! default pen size is label writes whatever at cursor location text goes in direction that turtle is pointing wait 20 put this between commands to slow turtle down so you can see what it's doing, for example: fd 100 rt 90 wait 20 fd 100Ħ page 4 PROGRAMMING FUNDAMENTAL 2: Repetition You already have experience with this one, too: We often repeat a sequence of commands. Find out how accurate your thinking is! The computer is your faithful servant: it will do exactly what you tell it to do. Try to map out all the steps in advance, then enter them at the command line. When you're designing a Logo drawing, think of the steps in the order that the computer should do them. Click a line in the history to make it jump to the command line, then make changes (or not) then press Enter or click Execute.Ĥ page 2 BASICS Don't forget spaces between words! forward 50 or or go forward 50 steps fd 50 right 90 or or right turn 90 degrees rt 90 fd 100 rt 90 fd 100 rt 90 makes two sides of a square several steps on command line are OK left 30 or lt 30 left turn 30 degrees back 100 or bk 100 go backward 100 steps clearscreen or cs erases all drawings and sets turtle at center useful at *beginning* of multi-step commands! PROGRAMMING FUNDAMENTAL 1: Sequence You have already experienced this one: Computers do commands in sequence. It's OK to write and run more than one command on line at a time.
Press Enter or click Execute to run command written there. Here's the MSW Logo screen in two parts: drawing window above, with triangle-shaped TURTLE in center Commander window below Write commands in command line, i.e., text box at bottom of Commander window.
Microsoft msw logo for free#
Contents Programming fundamentals 1: Sequence 2 2: Repetition 4 3: Subprograms 7 4: Variables 8 5: Decision-making 9 Strings 11 Recursive procedures 12 Turtle geometry 13 Color in Logo 14 Using code from other people's programs 17 Saving your pictures and programs 18 References 20ģ page 1 Logo programming If Logo is not already on your computer, you can get it for free from its makers at The installation process puts a Logo icon (as on the cover of this document) on your computer desktop. * My own web site offers code for things not included here. * There are web sites galore, many with program examples. I will be happy to help you, and you can get much more help by helping yourself: * There is a very extensive help system built into the Logo interpreter. There is way more to it than I can show you or tell you, even if we took an entire semester. 1 Logo PROGRAMMING WITH MSW Logo Computer Programming Fundamentals N V Fitton Northern Virginia Community College MSW Logo comes fromĢ Why learn Logo? * because it s fun * because it makes us want to think clearly * because it's real computer science Logo is easy to learn, as programming languages go, yet it also has enough depth to do virtually anything that can be done in any computer language.