locked
Cannot Find Operation "Angle" in "Turtle" ? RRS feed

  • Question

  • Hello. Im making an application that allows a user to control the turtle, and works well. But I have found something, when I added the ability to change the angle of the turtle in my code, Small Basic says it cannot find the operation Turtle.Angle. I'm not sure if it is an error in my code or Small Basic.

    Here is my code:
    http://smallbasic.com/program/?KXC855

    Also here is the subroutine of the angle command:

    Sub TurnAngle
      TextWindow.Write("Angle: ")
      angle = TextWindow.Read()
      TextWindow.Write("Left or Right")
      x = TextWindow.Read()
      If (x = "Left") Then
        Turtle.Turn(angle - angle*2)
      Endif
      If (x = "Right") Then
        Turtle.Turn(angle)
      EndIf
    EndSub

    Please Help!
    Thursday, May 28, 2009 5:53 PM

Answers

  • The problem is in your Random subroutine. 

    Sub Random
     lor = Math.GetRandomNumber(2)
     direct = Math.GetRandomNumber(360)
      am = Math.GetRandomNumber(300)
      If (lor = 1) Then
        Turtle.Angle(direct - direct * 2)
        Turtle.Move(am)
      Endif
      If (lor = 2) Then
        Turtle.Angle(direct)
        Turtle.Move(am)
      EndIf
    EndSub

    Turtle.Angle is a property, which needs to be set as follows:

      Turtle.Angle = direct - direct * 2

    which, by the way is the same as:

      Turtle.Angle = -direct

    • Marked as answer by Ironman14 Thursday, May 28, 2009 6:13 PM
    Thursday, May 28, 2009 5:59 PM

All replies

  • The problem is in your Random subroutine. 

    Sub Random
     lor = Math.GetRandomNumber(2)
     direct = Math.GetRandomNumber(360)
      am = Math.GetRandomNumber(300)
      If (lor = 1) Then
        Turtle.Angle(direct - direct * 2)
        Turtle.Move(am)
      Endif
      If (lor = 2) Then
        Turtle.Angle(direct)
        Turtle.Move(am)
      EndIf
    EndSub

    Turtle.Angle is a property, which needs to be set as follows:

      Turtle.Angle = direct - direct * 2

    which, by the way is the same as:

      Turtle.Angle = -direct

    • Marked as answer by Ironman14 Thursday, May 28, 2009 6:13 PM
    Thursday, May 28, 2009 5:59 PM
  • Thank you!

    That was a great help.

    Here is the working program:

    http://www.smallbasic.com/program/?RNH445


    Now just for the user to be able to record the turtles movements.
    Thursday, May 28, 2009 6:12 PM