# Very basic beginner help needed for turtle program

• ### Question

• I am 43 years old and have gone back to school taking Computer Software Support after a back injury left me unable to perform my work.  One of the classes I have to take is Principles of Programming.  The way this has gone so far, I'm very glad I didn't choose programming and I'm starting to doubt my choice of software support.  Anyways, here's my problem, I have to write a program that asks for the number of sides to the figure and if you want a dotted or solid line.  I have the program working to a point, but it only draws a dotted line no matter what the input is.  I have read everything I can find and am unable to come up with a solution to my problem.  Worst part is, I know it is something very simple and very basic, but I can't figure it out.  I am frustrated to the point of giving up, but I must pass the class in order to continue on regardless of if I change my major or not.  I don't necessarily want someone to say "here is the answer", but if someone could point me in the right direction I would appreciate it.  As I said, I know this is going to be a very simple solution, but don't worry about hurting my feelings.  At this point, they really don't matter anymore.  I will attach what I have written so far.
Thanks for any help,
Stacy

TextWindow.Write("Enter the number of sides you want the turtle to draw:  ")
TextWindow.Write("Do you want the Turtle to draw a solid or dotted line?  ")

length = 400 / sides
angle = 360 / sides

For i = 1 To sides

If (line = solid) Then
Turtle.Move(length)
Turtle.Turn(angle)
Else
For j = 1 To sides
Turtle.Move(length / 7)
Turtle.PenUp()
Turtle.Move(length / 7)
Turtle.PenDown()
EndFor
Turtle.Turn(angle)
EndIf
Thursday, December 10, 2009 1:36 AM

• Stacy, well done so far.

As you say, you are almost there and there is a very simple solution. The problem is with your IF line.  Any word you type into SmallBasic (that isn't a recognised command) is treated as a variable. Therefore, you are currently checking if your variable named 'line' equals your variable named 'solid', which it never will as you don't have a variable named 'solid'.

So, the very simple solution is to put the word 'solid' inside quotation marks, like so: "solid"  Once you do that, you will be comparing your variable named 'line' with a text string containing the word 'solid'.

Hope that helps.
• Marked as answer by Friday, December 11, 2009 2:45 PM
Thursday, December 10, 2009 8:55 PM

### All replies

• When you prompt the user to enter solid or dotted line, what do you expect user to enter?
TextWindow.Read() can except anything. And whatever the answer is, will be held in the variable call "line".

Suppose you are expecting someone enter either "solid" or "dotted" then variable LINE, will hold the string "solid" or "dotted".

You are already in the right direction, but it's there's a problem when you are comparing variable LINE with variable SOLID, because variable SOLID were never assigned any string, so you are comparing whether ("solid" = nothing) that's why it never get into the solid line and always fall into the ELSE statement.

Thursday, December 10, 2009 2:25 AM
• Stacy, well done so far.

As you say, you are almost there and there is a very simple solution. The problem is with your IF line.  Any word you type into SmallBasic (that isn't a recognised command) is treated as a variable. Therefore, you are currently checking if your variable named 'line' equals your variable named 'solid', which it never will as you don't have a variable named 'solid'.

So, the very simple solution is to put the word 'solid' inside quotation marks, like so: "solid"  Once you do that, you will be comparing your variable named 'line' with a text string containing the word 'solid'.

Hope that helps.
• Marked as answer by Friday, December 11, 2009 2:45 PM
Thursday, December 10, 2009 8:55 PM
• there's also another thing. when you draw a dotted shape, the shape is two times as big as the solid shape.
Live for nothing, OR CODE FOR SOMETHING!
Thursday, December 10, 2009 10:45 PM
• Thanks to everyone for their help and input.  I figured it out late yesterday afternoon.  Who would have thought that a set of "" could cause a person so much frustration?  Thanks again for taking the time to post.

Stacy
Friday, December 11, 2009 2:44 PM