With the current version of Small Basic, the trails left by the turtle cannot be easily cleared.  We may want to remove the trails because we are starting the turtle off again and want a clear screen or if the number of trails is very large the program will slow.

One obvious option would be to do a GraphicsWindow.Clear().  This does delete all shapes including the turtle trails, but unfortunately it also deletes the turtle itself which cannot then be restored.

There are extension methods to re-add the turtle or even change it to another image, but without an extension it appears that the turtle trails cannot be deleted.

However, there is a workaround.

The turtle trails are actually line shapes, similar to an object created with Shapes.AddLine and internally they are named "_turtleLine1", "_turtleLine2" etc.

So we can delete these with Shapes.Remove.  All we need to know is how many lines there are or just do it for a large number greater than the number of turtle lines that may have been drawn.

Here is an example:

'Create a turtle picture
Turtle.Speed = 10
For i = 1 To 600
  Turtle.Move(10)
  Turtle.Turn(i*11)
EndFor
 
'Pause then delete it
Program.Delay(1000)
For i = 1 To 1000
  Shapes.Remove("_turtleLine"+i)
EndFor

 

Finally, note that if we add more turtle trails after removing some, then the index number added to the trail name continues to be incremented by 1 and does not revert to start from 1.