Programming with MSWlogo


MSWLogo is an interpreter language based on Logo, with a GUI front end. Its core is the same as UCBLogo by Brian Harvey. It is free software, with source available, in Borland C++.

The Turtle:

Why a "Turtle"? - The original idea behind Logo was that a small robot device would be connected to the computer and made to move around the floor, drawing as it goes. The first such robot was a domed perspex device with wheels. It’s domed "shell' made it look like an electronic turtle. The robot 'turtle' has evolved into a graphical turtle on the screen. In some logos a representation of a turtle remains as the 'pointer'. In MSW Logo it has been reduced to a triangular pointer.

Logo Commands:
Command
Abbreviation
Result
FORWARD n
FD
 moves the turtle forward n units
BACK n
BK
 moves the turtle back n units
RIGHT n
RT
 turns the turtle n degrees to the right
LEFT n
LT
 turns the turtle n degrees to the left
HOME
none
 Returns the turtle to its origin
CLEARSCREEN
CS
 Erases the screen
HIDETURTLE
HT
Hide the turtle
SHOWTURTLE
ST
Show the turtle
REPEAT n[commands]
none
Repeats the commands n times
PENUP
PU
Lifts the pen as the turtle moves. The turtle stops drawing.
PENDOWN
PD
The turtle continues to draw as it moves.
PENERASE
PE
Sets the pen's position to DOWN and the mode to erase.
PENPAINT
PPT
Sets the pen's position to DOWN and the mode to PAINT. (PAINT is the normal mode.)
SETPENCOLOR [Red, Green, Blue]
setPC
Changes the pencolor. eg SETPENCOLOR [255, 0, 0] = Red, SETPENCOLOR [0, 255,0] = Green, SETPENCOLOR [0, 0, 255] = Blue

Things can do with logo:
Move multiple turtles at once
Produce fonts
Color objects
Cut and paste
Give status reports
Make sounds
Work in 3D and view in 3D
Create solids


MSWLogo in an interpreter of Logo programming language. This easy to use language was created for educational matters. Its interface is simple and easy to use. With a window where may see the outcome of our program, and another one for introducing commands. The programs allows to introduce changes in the way that graphics are created (the color and width of each stroke, and the size and type of foundation, etc.). Also it lets you adjust the area that is visible,


Programming with MSW Logo

Triangle
Repeat 3[fd 200 rt 120]



Hexagon
Repeat 6[fd 200 rt 60]




Square
Repeat 4[fd 200 rt 90]   



Rectangle
Repeat 2[fd 100 rt 90 fd 200 rt 90]




Figure 1
rt 45
fd 250
setpc 3
repeat 4[rt 90 fd 100]
setpc 0
bk 250
rt 45
pu fd 100
lt 135
pd fd 250
setpc 5
repeat 4[rt 90 fd 100]
setpc 0
bk 250


                                                              Figure 2

setpc 2
Repeat 4[fd 100 rt 90]
setpc 13
Repeat 4[fd 200 rt 90]
setpc 4
Repeat 4[fd 300 rt 90]





No comments:

Post a Comment