RoBOTL Execution
Statements

"execute" Statements are functions which you can call within the "execute" section of a RoBOTL program. Statements are used to create new robots, place worlds, etc.

Statements can be used singularly, or in groups. The "execute" Statements are:


Assignment

Usage: Variable "=" Expression ";"

Assignment statements set a given variable equal to some expression. This statement can only modify the defined global variables.


Do-While

Usage: Do Statements While "(" Expression ")" ";"

The Do-While statement is much like the While statement, except the loop is executed first, and then the expression is checked.


If-Else

Usage: If "(" Expression ")" Statements [ "Else" Statements ]

The If-Else conditional statement is one of the basics in modern programming. If the given Expression is true (defined as a non-zero value), then the first set of Statements are executed. If the expression is false (a value of zero), the statements are ignored.

If the optional '"Else" Statements' section is added, the statements following the "else" is executed if the first expression is false. This might sound a little confusing, but this example should help:

define {
       DefineGlobalInteger true  = 1;
       DefineGlobalInteger false = 0;
}
execute {
	if ( true ) // Always going to execute the statements.
	   [statements]
	if ( false ) // Never going to execute the statements.
	   [statements 1]
	else [statements 2]	/* Since false is never true,
				   statements 2 will be executed. */
}


Iterate

Usage: Iterate Expression "times" Statements

The iterate statement allows you to have some set of statements repeated for a specific number of times, specified by Expression. For instance:

iterate 4 times variable = variable + 1;

This statement will add 4 to the initial value in variable. (Note: This is a random example, and the overall effect can be achieved using a more efficient statement such as 'variable = variable + 4;'.)


New

Usage: New Robot Type Robot Name [ "at" Coordinates ] ";"

The New statement is used to create a new robot in the world of RoBOTL. The robot will be of type Robot Type, and be named Robot Name, using the above statement layout. By default, robots are placed at the bottom-left corner of the map (coordinates (0, 0)), but with the optional '"at" Coordinates' after the Robot Name, you can place the robot anywhere on the map.


Place

Usage: Place World Name [ "at" Coordinates ] ";"

The place statement is used to lay a world (as defined with the WorldEntity "define" statement) onto the RoBOTL map. By default, the world is placed with it's lower left corner at (0, 0). You can change this by using the optional '"at" Coordinates'.

Note: If there is no conflict when placing parts of the world (overlapping objects in a square), the Rules of Placement are followed.


Tell

Usage: Tell Robot Name ":" Instructions

The Tell Statement is used to give instructions to a specific robot, identified as Robot Name above. You can not tell a robot which is turned off to do anything.


Remove

Usage: Remove Robot Name ";"

The Remove statement will remove the named robot from the map.


TurnOff

Usage: TurnOff "all" ";"

If you wish to turn all of the robots on the map off, use this statement.


TurnOn

Usage: TurnOn "all" ";"

If you wish to turn all of the robots on the map on, you can use this statement.

Note: Robots who are damaged (by hitting an object) and are turned off can NOT be re-activated by the turnon statement.


While

Usage: While Expression Statements

This statement will execute the given statements as long as the expression is true. Note that the expression is checked before the first time through the while loop, so if the expression is initially false, the loop is ignored.


This guide is not great to look at under text-only browsers. Sorry. Since you need a graphical browser for the applet, we figured you'd be using it for the reference guide.

Document Last Revised: Tuesday December 16th, 1997 at 1:32am
Copyright ©1997 Worcester Polytechnic Institute
Page Written by: Theo Van Dinter (felicity@kluge.net)