Ask Learn
Preview
Ask Learn is an AI assistant that can answer questions, clarify concepts, and define terms using trusted Microsoft documentation.
Please sign in to use Ask Learn.
Sign inThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Algorithm is combinations of code patterns. Today, I'd like to introduce three basic code patterns. I also wrote a sample program for this blog: LMR321.
Sequence of statements is the simplest pattern of code. But sometimes the order of statements becomes very important.
Following two code blocks show the different results.
Turtle.Move(100) ' move first
Turtle.Turn(90)
Turtle.Turn(90) ' turn first
Turtle.Move(100)
In a program, we sometimes need to repeat something. We can also write same lines of code, but a loop makes it simpler. Following two code blocks show the same results.
TextWindow.WriteLine("Hello World!")
TextWindow.WriteLine("Hello World!")
TextWindow.WriteLine("Hello World!")
TextWindow.WriteLine("Hello World!")
For i = 1 To 4
TextWindow.WriteLine("Hello World!")
EndFor
There are some cases we'd like to change doing with conditions such as input data or current status. We can do this kind of selection with If statement like following code.
If Turtle.Y < yCenter Then
TextWindow.WriteLine("UPPER")
Else
TextWindow.WriteLine("LOWER")
EndIf
Ask Learn is an AI assistant that can answer questions, clarify concepts, and define terms using trusted Microsoft documentation.
Please sign in to use Ask Learn.
Sign in