User Guide
While Keywords
71
Axcess Programming Language
While Keywords (Cont.)
LONG_WHILE In cases where a WHILE loop takes longer than one half-second to execute,
change the WHILE keyword in question to a LONG_WHILE.
You must provide a way out of your LONG_WHILE (by allowing the condition to
become false), the program will become stuck inside the LONG_WHILE and no
other code outside of the loop will be executed.
Example:
DEFINE_VARIABLE
WHILE_TIMEOUT (* FOR LONG_WHILE TIMEOUT *)
DEFINE_PROGRAM
RELAY_INDEX = 1
WHILE_TIMEOUT = Ø
WAIT 3Ø (* FORCE LONG_WHILE TO
TIMEOUT AFTER 3 SECONDS *)
WHILE_TIMEOUT = 1
LONG_WHILE ((RELAY_INDEX <= 14) && (!WHILE_TIMEOUT))
{
ON[RELAY,RELAY_INDEX]
RELAY_INDEX = RELAY_INDEX + 1
}
In the example above, a variable called WHILE_TIMEOUT (a flag used to force
the program out of the LONG_WHILE) is added. Before starting the
LONG_WHILE loop, initialize the timeout flag to Ø, and set the RELAY_INDEX
(the relays that will turn on first) to 1. Then start a three-second wait to set
WHILE_TIMEOUT to 1. The WAIT keyword tells the Central Controller the fol-
lowing code needs to be executed at some later time. The time is specified
right after the WAIT keyword in tenths of a second. In this example, WAIT 3Ø is
three seconds. The Central Controller remembers that in three seconds it
should execute the line of code:
WHILE_TIMEOUT = 1.
Now start the LONG_WHILE. The statements inside the LONG_WHILE exe-
cute until the condition after the LONG_WHILE becomes false. This occurs
either when RELAY_INDEX reaches a value greater than 14, or the
WHILE_TIMEOUT variable becomes 1. Inside the LONG_WHILE, turn on the
relay RELAY_INDEX, and increment RELAY_INDEX. The LONG_WHILE will
turn on relays 1-14. If the master were to spend more than three seconds turn-
ing on these relays, it will exit the LONG_WHILE and execute the code follow-
ing the LONG_WHILE.