
Squishymole wrote: " We're gonna need a bigger plane " posted to Write a Funny Caption For This Photo.PickleOk wrote: " Is the plane running alright, pilot? " posted to Write a Funny Caption For This Photo." posted to Write a Funny Caption For This Photo. Roo8 wrote: " I think I need a boat maby a cruise ship.Bigbilly wrote: " Gotta get back to africa " posted to Write a Funny Caption For This Photo.This helps you by enabling you to have one program that runs all of the missions and that one program is flexible enough that you could re-start at any one particular mission and the rest of the sequence would flow normally from that point. You can tell the robot to start at mission 3 and it will do 3, 4, and 5. Now you can tell the robot to start at Mission 1 and it will do 1, 2, 3, 4, and 5.

Now think of each function as a " mission" to be performed. Whatever the selectedItem is, the robot will start with the function and then perform the remaining functions in order. Let's get rid of the default from the block. In essence, the robot will start at the selectedItem and will then do every action in order from that point on. If the selectedItem is number three (3), then the robot will doFunction3() and will then go on from there. If the selectedItem is number one (1), then the robot will doFunction1() and then go on to case 2 and will doFunction2() and then go on to case 3 and will doFunction3(). }Without the break statements, the program does not exit the switch block until the end. What would it look like without the break statements? Interesting Adjustment: What happens if we take out the break statements? If the selectedItem is the third one, then we will doFunction3() afterwhich we will break and seek new input from the user.

If the selectedItem is the second one, then we will doFunction2() afterwhich we will break and seek new input from the user. If the selectedItem is the first one, then we will doFunction1() afterwhich we will break and seek new input from the user.
#ROBOTC HOW TO PROGRAM CODE#
}This code is telling the robot that we will "switch" the actions that will be performed depending on the particular index value of the "selectedItem". When the user makes their selection, a value of the menu item is returned to be analyzed to determine what course of action to take. Let's say that a user is presented with a menu of items to choose from. If the different expressions are all looking at a common variable, there is a shortcut you can use to save space: switch case. One drawback is that this does seem to take a lot of lines of code. It may be necessary to check several different expressions and perform different actions depending on them. Many beginning programmers start building control structures using " if" blocks. To understand what is missing, let's take a look at some of the common ways these control structures are written. It was left out on purpose in order to achieve this desired effect. The key feature of this program is actually something that is missing.

There is a key feature of this program that enables you to select where the robot starts in the mission sequence. This program will sequence of missions and you can specify where in the sequence the robot starts. This is an experiment in the use of a control program that is able to run multiple missions.

