Programming
Home What is Logo? Getting Logo Logo Lessons Tic-Tac-Toe Downloads

 

Design
Programming
Initialize
Grid
Winning
Two Player
Single Player

Back Up Next

Programming

Logo is a word-orientated language, and we build up the program by teaching Logo new words based on existing words (otherwise known as defining procedures). An example word in logo is "forward". If we tell logo to do something, we will type a series of words and values for those words, which forms a command.

I use the following notation when you need to type commands in the commander:

Commander
forward 50
show 5
5

This means, "Type the command 'Forward 50' in the Commander window, press Enter or click on Execute. Type the command 'show 5' at the command prompt, press Enter or click on Execute. You should see the value '5' displayed." You will see all three lines in the history portion of commander.  

When we need to teach Logo a new word, I will show the definition (a sequence of existing words) as follows:

Editor
to aaa
;
; tictactoe
;
; type "tictactoe" or "go" to start
;
; plays until either nobody can move
; or there's a winner
;
end

This is also called a procedure. You can think of this as Logo proceeding to follow the instructions you gave it. Notice the first word is "to" and the last word is "end". You can type "to aaa" in the commander, and then enter the definition a line at a time. However, I recommend using "edit" instead. Type:

Commander
edit "aaa

There must not be a space after the quote. You will see an edit box that looks like the following: 

Type in the definition, so it looks as follows: 

Select the editor's "File" menu and click on "Save and Exit". This will save the new word definition (in this case, just information) into the workspace. You can modify this word's definition by editing it again:

Commander
edit "aaa

Whenever you see a command beginning with the word "to" this means it's a definition, and you should enter it into the editor using "edit".

You can save the workspace (I recommend doing this at least after every task) by selecting the MSWLogo Screen "File" menu and clicking on "Save" or "SaveAs". Another way of saving (as long as you know where the file is being saved to) is by using the "save" word:

Commander
save "tictactoe.lgo

If you exit, and then later want to continue where you left off, you can recover the workspace by selecting the "File" menu and clicking on "Load". Select the file that the workspace was saved to, and all the words you have defined will be loaded. You can look at all the words currently defined (by you), and define new ones by selecting "File" menu and clicking on "Edit". If you want help on a particular logo word, press "F1" (or select Help menu) for online help.

Back Up Next

 

Comments to WebMaster