Microsoft Small Basic

Program Listing: HQB864
'Recipe & Cheat sheet
'For Loop Shape
'Draw a shape with user provided input.
'Use For loop to draw circle
'Teaches variables, graphicswindow, geometry, and division

'Write a line of text using the textwindow that asks "What is your name?"
TextWindow.Write("What is your name? ")

'Set the variable "name" to the name entered on the line above.
name=TextWindow.Read()

'Write a line of text using the textwindow that asks "How many sides do you want you shape to have?"
TextWindow.Write("How many sides do you want your shape to have? ")

'Set the variable "sides" to the amount of sides entered on the line above.
sides=TextWindow.Read()

'Set the variable "angle" to the number of sides needed to create closed shape (cirle, square, trianlge, pentagon, ect....).
'HINT: You can use division in the code. Example for a square would be (360/4)
angle=(360/sides)

'Write a line of text using the textwindow that asks "How long do you want each line to be in pixels? "
TextWindow.Write("How long do you want each line to be? ")

'Set the variable "length" to the size entered on the line above
length=TextWindow.Read()

'Write a line of text using the textwindow that asks "How fast do you want YOUR NAME to move (1-10)? "
TextWindow.Write("How fast do you want "+name+" the Tortoise to move? ")

'Set the variable "speed" to the speed entered on the line above.
speed=TextWindow.Read()

'Set the Tortoise speed to the variable "speed"
Tortoise.SetSpeed(speed)

'Create the first line of your "for loop" (hint For i= 1 to sides)
For i = 1 To sides

'Make the Tortoise move the amount in the variable "length"
Tortoise.Move(length)

'Make the Tortoise turn the amount in the variable "angle"
Tortoise.Turn(angle)

'End your "for loop"
EndFor

'Display a message to the graphics window praising you for your fine work!
'Hint:GraphicsWindow.DrawText
GraphicsWindow.DrawText(100,100,"Well Done "+name+" the Tortoise!!!")