# Small Basics Turtle Storage • ### Question

• Hello,

I am doing a Learning Task that involves me making a Turtle Program run 3 or more routes around my school, I've done an 'If And Then' Statement and added a bookmark for later, and when I return to that bookmark, it does a loop from the bookmark to the Goto Statement and then goes back in a continuous loop.

Here is the current code.

'Opening the Western Port Secondary School grounds map'
GraphicsWindow.Show()
GraphicsWindow.Title = "Western Port Secondary College Map with Turtle"
GraphicsWindow.Width = 700
GraphicsWindow.Height = 500
image1 = "file:///C:/Users/CORY/Pictures/School%20Pictures/WPSC_Map.JPG"
GraphicsWindow.DrawResizedImage(image1, 0, 0, 660, 441)

'Setting a starting point for Turtle'
Turtle.Show()
Turtle.X = 152
Turtle.Y = 123

'Setting Variables for Turtle's start point for when he finishes a route'
'Also getting other variables ready for later on'
a = Turtle.X
b = Turtle.Y

'Getting Turtle started'
'The first route, my mostly used route to go to the STEM center'
GraphicsWindow.PenColor = "Lime"

Turtle.Speed = 10

Turtle.Turn(125.6)
Turtle.Move(113)
Turtle.Turn(-35.6)
Turtle.Move(10)
Turtle.TurnRight()
Turtle.Move(5)
Turtle.TurnLeft()
Turtle.Move(3)
Turtle.Turn(60)
Turtle.Move(63)
Turtle.Angle = 180
Turtle.Move(5)
Turtle.TurnLeft()
Turtle.Move(60)

'Creating the variables for the end point for Turtle to move to'
FinalX = Turtle.X
FinalY = Turtle.Y

'This is the start of the final path for the end point, using Branching and conditions to store it for later'
i = 1
Finish:
If (Turtle.X = FinalX)And(Turtle.Y = FinalY) Then
Turtle.Angle = 153
Turtle.Move(68)
Turtle.Angle = 180
Turtle.Move(34)
Turtle.TurnLeft()
Turtle.Move(5)
Turtle.PenUp()
Turtle.Speed = 9
Turtle.MoveTo(a, b)
Turtle.Speed = 5
Turtle.Angle = 0
EndIf

'Beginning my second path'
Turtle.PenDown()
GraphicsWindow.PenColor = "DarkBlue"
Turtle.Turn(166)
Turtle.Move(93)
Turtle.Turn(-40)
Turtle.Move(50)
Turtle.Turn(-36)
Turtle.Move(73)
Turtle.TurnRight()
Turtle.Move(10)
Turtle.MoveTo(FinalX, FinalY)
Goto Finish

'This code was for test'
'Turtle.PenUp()
'Turtle.MoveTo(FinalX, FinalY)
'Turtle.MoveTo(a, b)
'Turtle.Speed = 10

'This code is to hide the turtle so I can see where the line ends'
Turtle.Hide()

I'm currently trying to figure out how to do a For and a While statement.

Thank you

------

I'd like to know how to store a code for later use

'Creating the variables for the end point for Turtle to move to'
FinalX = Turtle.X
FinalY = Turtle.Y

'This is the start of the final path for the end point, using Branching and conditions to store it for later'
i = 1
Finish:
If (Turtle.X = FinalX)And(Turtle.Y = FinalY) Then
Turtle.Angle = 153
Turtle.Move(68)
Turtle.Angle = 180
Turtle.Move(34)
Turtle.TurnLeft()
Turtle.Move(5)
Turtle.PenUp()
Turtle.Speed = 9
Turtle.MoveTo(a, b)
Turtle.Speed = 5
Turtle.Angle = 0
EndIf

• Edited by Wednesday, August 7, 2019 4:25 AM New question
Thursday, August 1, 2019 11:15 AM

• Perhaps you want to put that bit if code in a subroutine that you can call one or more times?
• Marked as answer by Thursday, August 8, 2019 1:25 AM
Wednesday, August 7, 2019 8:16 AM

### All replies

• The problem is after the 5th or 6th Comment.

Thursday, August 1, 2019 11:16 AM
• Your program is continous repeating the goto Finish and drawing the blue line.

I suspect this not what you want. What is "the problem is after the 5th comment" ?

Jan [ WhTurner ] The Netherlands

Thursday, August 1, 2019 12:00 PM
• So I think the problem starts from the;

'Creating the variables for the end point for Turtle to move to'
FinalX = Turtle.X
FinalY = Turtle.Y

Or something like that...

I just want to  this bit to be stored for later on;

'This is the start of the final path for the end point, using Branching and conditions to store it for later'
i = 1
Finish:
If (Turtle.X = FinalX)And(Turtle.Y = FinalY) Then
Turtle.Angle = 153
Turtle.Move(68)
Turtle.Angle = 180
Turtle.Move(34)
Turtle.TurnLeft()
Turtle.Move(5)
Turtle.PenUp()
Turtle.Speed = 9
Turtle.MoveTo(a, b)
Turtle.Speed = 5
Turtle.Angle = 0
EndIf

Friday, August 2, 2019 9:11 AM
• It's not clear what you want. Do you want to keep (a part of) the data in a file to be used later, after a new start of the program?

Otherwise give a short description of how you want to use the program.

Jan [ WhTurner ] The Netherlands

Friday, August 2, 2019 12:34 PM
• Hi Cory, I modified your program to show four points A, B, C, D.  Now your program goes A - B (green root) - C (red root), A - D (blue root) - B - C (red root), A - D (blue root) - B - C (red root) ...

While A = (a, b), B = (FinalX, FinalY), C = end of red root, D = last point to B of blue root.

Which root do you want to go?

```'Opening the Western Port Secondary School grounds map'
GraphicsWindow.Show()
GraphicsWindow.Title = "Western Port Secondary College Map with Turtle"
GraphicsWindow.Width = 700
GraphicsWindow.Height = 500
image1 = "file:///C:/Users/CORY/Pictures/School%20Pictures/WPSC_Map.JPG"
GraphicsWindow.DrawResizedImage(image1, 0, 0, 660, 441)

'Setting a starting point for Turtle'
Turtle.Show()
Turtle.X = 152
Turtle.Y = 123

'Setting Variables for Turtle's start point for when he finishes a route'
'Also getting other variables ready for later on'
a = Turtle.X
b = Turtle.Y
GraphicsWindow.BrushColor = "Black"
GraphicsWindow.DrawText(a, b, "A")

'Getting Turtle started'
'The first route, my mostly used route to go to the STEM center'
GraphicsWindow.PenColor = "Lime"

Turtle.Speed = 10

Turtle.Turn(125.6)
Turtle.Move(113)
Turtle.Turn(-35.6)
Turtle.Move(10)
Turtle.TurnRight()
Turtle.Move(5)
Turtle.TurnLeft()
Turtle.Move(3)
Turtle.Turn(60)
Turtle.Move(63)
Turtle.Angle = 180
Turtle.Move(5)
Turtle.TurnLeft()
Turtle.Move(60)

'Creating the variables for the end point for Turtle to move to'
FinalX = Turtle.X
FinalY = Turtle.Y
GraphicsWindow.DrawText(FinalX, FinalY, "B")

'This is the start of the final path for the end point, using Branching and conditions to store it for later'
i = 1
Finish:
If (Turtle.X = FinalX)And(Turtle.Y = FinalY) Then
GraphicsWindow.PenColor = "Red"
Turtle.Angle = 153
Turtle.Move(68)
Turtle.Angle = 180
Turtle.Move(34)
Turtle.TurnLeft()
Turtle.Move(5)
Turtle.PenUp()
Turtle.Speed = 9
GraphicsWindow.DrawText(Turtle.X, Turtle.Y, "C")
Turtle.MoveTo(a, b)
Turtle.Speed = 5
Turtle.Angle = 0
EndIf

'Beginning my second path'
Turtle.PenDown()
GraphicsWindow.PenColor = "DarkBlue"
Turtle.Turn(166)
Turtle.Move(93)
Turtle.Turn(-40)
Turtle.Move(50)
Turtle.Turn(-36)
Turtle.Move(73)
Turtle.TurnRight()
Turtle.Move(10)
GraphicsWindow.DrawText(Turtle.X, Turtle.Y, "D")
Turtle.MoveTo(FinalX, FinalY)
Goto Finish

'This code was for test'
'Turtle.PenUp()
'Turtle.MoveTo(FinalX, FinalY)
'Turtle.MoveTo(a, b)
'Turtle.Speed = 10

'This code is to hide the turtle so I can see where the line ends'
Turtle.Hide() ```

Nonki Takahashi

Friday, August 2, 2019 12:44 PM
• Here's a teeny turtle exploring the world. We'll have to take care, that it stays on land, it's not a sea turtle.

DMB122

Friday, August 2, 2019 9:27 PM
• I'd like to keep the data for later on in the code.

Wednesday, August 7, 2019 4:17 AM
• Well it's a bit difficult to show you the map because of the file but all I need is help with storing a part of a code for later on in the code to call back and do that code but I do not want it to loop.
Wednesday, August 7, 2019 4:19 AM
• Perhaps you want to put that bit if code in a subroutine that you can call one or more times?
• Marked as answer by Thursday, August 8, 2019 1:25 AM
Wednesday, August 7, 2019 8:16 AM
• Took me a while to figure out how to do a subroutine, but it works.

Thanks.

Thursday, August 8, 2019 1:26 AM