Вы находитесь на странице: 1из 4

EXPLORING

PROGRAMMING

Assignments
Spring2003
Assignments
CollaborativeWeb
TriClass
Reflection

Course
Information
CourseOverview

COMMONMSWLOGO
COMMANDS

ExploringProgramming|Academics|MiddleSchool|TheAmericanSchoolinJapan

PenandColor|Move|Turtle|Program|MathematicsandVariables|ProgramFlow
|Mouse

PenandColorCommands
PU

CourseSyllabus

Resources
Search
CommonLogo
Commands

PD

Shortfor"penup,"itliftsthe"pen"fromthescreensothatmovingthe
turtledoesn'tdrawaline.
Example:PU

Putsthependownsothatmovingtheturtledrawsaline
Example:PD
LogoPrograms
SetPenSize[nn]
Squeak
Setsthewidthofthepentonpixels.Notethatitisnecessarytoputin
Resources
twonumbers.
VisualBasic
Example:SetPenSize[55]
Resources
SetPC[rgb]
OtherLanguages
SetsthepencolortotheappropriateRGB(Red,Green,Blue)values,
Javascript
wherer,g,andbarenumbersthatrangefrom0to255.(Non
Alice
integersarerounded.)
Example:SetPC[25500](Givesred)
Penerase
Setsthepentodownandsetsthemodetoerase.Whenthepenis
moved,itwillerasewhateverisunderit.Anabbreviationispe.
Example:Peneraseorpe
Pennormal
Setsthepenbacktonormalmodeandcancelserasemode.
Example:Penerase
setfloodcolor[rgb]
SetsthefloodcolortotheappropriateRGB(Red,Green,Blue)values,
wherer,g,andbarenumbersthatrangefrom0to255.(Non
integersarerounded.)
Example:setfloodcolor[2550255](Givesmagenta)
fill
Floodstheareaboundedbylineswithwhatevercolorwasspecifiedin
thesetfloodcolorcommand.
Example:fill
Move(drawing)commands
FDx
Moveforwardxpixels
Example:FD100
BKx
MoveBackwardxpixels
Example:BK100
LTx
Rotatetheturtlexdegreesleft

Example:LT45
RTx
Rotatetheturtlexdegreesright.
Example:RT45
ARCar
Drawanarcwithanincludedangleofadegreesandradiusofr.
However,theturtleremainsatthecenterofthearc.
Example:ARC45100
ARC2ar
Drawanarcwithanincludedangleofadegreesandradiusofr.
However,theturtleendsupattheendofthearc.
Example:ARC45100
TurtleandPositionCommands
ST
HT

Showsthecurrentturtle.
Example:ST

Hidesthecurrentturtle.
Example:HT
Orientation
Returnsathreememberlistwiththeorientationoftheturtle.Intwo
dimensions,weareonlyconcernedwiththelastelementinthelist.
Youcaneitherassignthelisttoavariable,orgetavaluefromthelist.
Example:Orientation
Make"startangleLASTOrientation(Assignsthevalueofthe
turtle'sxpositiontothevariablestartangle)
Pos
Returnsatwomemberlistwiththexandypositionoftheturtle.You
caneitherassignthelisttoavariable,orgetavaluefromthelist.
Example:POS
Make"xstartpositionFIRSTPOS(Assignsthevalueoftheturtle'sx
positiontothevariablexstartposition)
setorientation[rollpitchheading]
Usesathreeelementlisttosetthepositionoftheturtle.Intwo
dimensions,weareonlyconcernedwiththeheadingelementinthe
listbutallthreeelementsareneeded.
Example:setorientation[0090]Leavestheturtlepointing90
degreesfromstraightup
setpos[xy]
Setstheabsolutexandpositionoftheturtle.Ifthepenisdown,it
willdrawalinefromit'spreviousposition.
Example:setpos[10090]Setstheturtlex=100andy=90.
SetTurtlen
Changestoturtlenwiththefirstturtlebeingturtle0andthelast
beingturtle1023.Notethatitcreatesalloftheturtlesbetween0and
theonespecified,soSetTurtle100willcreateturtles199ifthey
havenotyetbeencreated.
Example:SetTurtlen
SetTurtlen
Changestoturtlenwiththefirstturtlebeingturtle0andthelast
beingturtle1023.Notethatitcreatesalloftheturtlesbetween0and
theonespecified,soSetTurtle100willcreateturtles199ifthey
havenotyetbeencreated.
Example:SetTurtlen

ProgramCommands
Tonamearg1arg2....
Startsaprocedure,calledname,thattakesoptionalargumentsarg1
arg2.....
Examples:ToSquare
Torpolygon:numsides:sidelength:numrepeats
End
Markstheendofaprocedureandisrequired.
Example:End

CS
Anabbreviationforclearscreen,itclearsthescreenandreturnsthe
mousetoit'shomeposition.
Example:End

Repeatn[instructionlist]
Repeatstheactionslistedintheinstructionlistannnumberof
times.
Examples:Repeatn[fd10lt90square]or
Repeat:numrepeat[fd10polygon:angle:sidelength]
Show
Showsinthecommanderwhateveryouask.Itcanbeavalueoran
instructionlist.
Waitn
Pausesforthespecifiedamountoftime,measuredin1/60seconds,
beforeexecutingthenextcommand.So,ifnis60,theprogramwill
pausefor1second.
Example:Random30
MathematicsandVariablesCommands
Randomn
Returnsanintegerrandomnumberthatrangesfrom0tojustlessthan
n.Forexample,ifnis10,therandomnumberswillbe0,1,2,3,4,5,
6,7,8,or9.
Example:Randomn
Make"namex
Assignsthevaluextothestringname.Noticethedoublequotesin
frontofname?ThosearenecessarytotellLogothatnameisastring.
Howeveronceyouhavedefinednameasavariableyoumayreference
thatvariablebyusingthecolonbeforename,i.e.:name
Examples:Make"side15.5
Make"halfside:side/2
ProgramFlowCommands
FOR[istartstopstep][InstructionList]
ThisistheclassicForNextloop.Thefirstword,i,isavariablethe
holdsthecurrentvalueofthecounter.Traditionally,itisibutitcanbe
anyvariable.Youcangetthevalueofthecounterjustbyreferringto
thevariable.Theotherthreewordstellwheretostart,wheretostop,
andwhatthestepshouldbe.Thestepisoptionalandwillbesetto1
or1ifomitted.Theinstructionlististhelistofinstructionsthatwillbe
repeatedwhenevertheloopexecutes.

Examples:FOR[i0:angle][squarert1wait1]Thiswillexecute
theproceduresquareandturnrightonedegreeeachtimeitthrough
theloop.Theloopstopsoncethevalueofthevariable:angleis
reached.
FOR[counter0154][show:counter]Tryitandsee.

Othercommandsthathelpyoucontrolprogramfloware:do.while,If,
IfelseLooktheseupinthehelpfilefortheprogram.
MouseCommands
Readtheinformationonmouseonandmouseoffintheprogram'shelp
file.

Вам также может понравиться