June 2005
Beginner to intermediate
336 pages
6h 29m
English
Having read all the commands to execute, you can loop over those commands with a for loop. Each command, such as t:abc, which sends the text “abc” to the program the Robot project is controlling, is made up of an operation (“t” for text here) and data (“abc” here).
Here's how the Robot project extracts the operation and data from each command as it loops over all commands:
public void actionPerformed(ActionEvent e)
{
try{
.
.
.
for (int loopIndex = 0; loopIndex < numberCommands;
loopIndex++){
String operation = commands[loopIndex].substring(0, 1);
String data = commands[loopIndex].substring(2);
.
.
.
Each command is a single character, so you can use a switch statement to handle them all. Each operation ...
Read now
Unlock full access