Microsoft Small Basic

Program Listing: LMR321
' Algorithm Basics
' Copyright © 2016 Nonki Takahashi. The MIT License.

Init()

' Squence
GraphicsWindow.PenColor = "Green"
Turtle.Move(100)
Turtle.Turn(90)
Turtle.Move(100)
Turtle.Turn(90)
Turtle.Move(100)
Turtle.Turn(90)
Turtle.Move(100)
Turtle.Turn(-30)

' Loop
GraphicsWindow.PenColor = "Orange"
x = Turtle.X
y = Turtle.Y
While (Turtle.X <> x) Or (Turtle.Y <> (y - 100))
Turtle.Move(100)
Turtle.Turn(60)
EndWhile

' Selection
GraphicsWindow.BrushColor = "DarkCyan"
x = Turtle.X
y = Turtle.Y
If y < gh / 2 Then
pos = "UPPER "
Else
pos = "LOWER "
EndIf
If x < gw / 2 Then
pos = pos + "LEFT"
Else
pos = pos + "RIGHT"
EndIf
GraphicsWindow.DrawText(x, y - 30, pos)

Sub Init
GraphicsWindow.Title = "Algorithm Basics"
gh = GraphicsWindow.Height
gw = GraphicsWindow.Width
GraphicsWindow.PenColor = "LightGray"
GraphicsWindow.DrawLine(gw / 2, 0, gw / 2, gh)
GraphicsWindow.DrawLine(0, gh / 2, gw, gh / 2)
GraphicsWindow.FontBold = "False"
GraphicsWindow.FontSize = 20
GraphicsWindow.FontName = "Trebuchet MS"
EndSub