GraphicsWindow.Title = "Turtle Controller 0.1"
Init()
While "True"
GetCmd()
tx = Turtle.X
ty = Turtle.Y
If cmd = "0" Then
GraphicsWindow.Clear()
tx = gw / 2
ty = gh / 2
Turtle.Show()
Turtle.X = tx
Turtle.Y = ty
Turtle.Angle = 0
ElseIf cmd = "2" Then
Turtle.MoveTo(tx, ty - 50)
ElseIf cmd = "4" Then
Turtle.MoveTo(tx - 50, ty)
ElseIf cmd = "6" Then
Turtle.MoveTo(tx + 50, ty)
ElseIf cmd = "8" Then
Turtle.MoveTo(tx, ty + 50)
EndIf
Program.Delay(200)
EndWhile
Sub GetCmd
GetLine()
If line <> "" Then
If line = "FFFFFFFF" Then
code = lastLine
n = n + 1
Else
code = line
n = 1
EndIf
If n <> 2 Then
cmd = ctrl[code]
Else
cmd = ""
EndIf
If line <> "FFFFFFFF" Then
lastLine = line
EndIf
Else
cmd = ""
EndIf
EndSub
Sub GetLine
len = Text.GetLength(buf)
If p <= len Then
line = Text.GetSubText(buf, p, len - p + 1)
nl = Text.GetIndexOf(line, CRLF)
If 0 < nl Then
line = Text.GetSubText(line, 1, nl - 1)
p = p + nl + 1
Else
line = ""
EndIf
Else
line = ""
EndIf
EndSub