Crestron SIMPL+ Dokumentacja Strona 31

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj
  • Strona
    / 60
  • Spis treści
  • BOOKMARKI
  • Oceniono. / 5. Na podstawie oceny klientów
Przeglądanie stron 30
Crestron SIMPL+
Software
Examine an example using the switch-case construct. Perhaps there is a variable that
should hold the number of days in the current month. The following example uses
switch-case to set the value of this variable.
switch (getMonthNum())
{
case (2): //February
{
if (leapYear) // this variable was set elsewhere
numdays = 29;
else
numdays = 28;
}
case (4): // April
numdays = 30;
case (6): // June
numdays = 30;
case (9): // September
numdays = 30;
case (11): // November
numdays = 30;
default: // Any other month
numdays = 31;
}
Notice that curly braces did not enclose many of the statements in the previous
example. For most SIMPL+ constructs, the braces are only needed when more than
one statement is to be grouped together. If the program has only a single statement
following the case keyword, then the braces are optional.
Controlling Program Flow: Loops
“Controlling Program Flow: Branching” (on page 24) discussed constructs for
controlling the flow of a program by making decisions and branching. Sometimes a
program should execute the same code a number of times. This is called looping.
SIMPL+ provides three looping constructs: the for loop, the while loop, and the do-
until loop.
for Loops
The for loop is useful to cause a section of code to execute a specific number of
times. For example, consider clearing each element of a 15-element string array (set
it to an empty string). Use a for loop set to run 15 times and clear one element each
time through the loop.
Control the number of loops a for loop executes through the use of an index variable,
which must be an integer variable previously declared in the variable declaration
section of the program. Specify the starting and ending values for the index variable,
and an optional step value (how much the variable increments by each time through
the loop). Inside the loop, the executing code can reference this index.
The syntax of the for loop is as follows.
for (<variable> = <start> to <end> step <stepValue>)
{
// code in here executes each time through the loop
}
Programming Guide – DOC. 5789A SIMPL+
27
Przeglądanie stron 30
1 2 ... 26 27 28 29 30 31 32 33 34 35 36 ... 59 60

Komentarze do niniejszej Instrukcji

Brak uwag

Krystal Touch of NY DL3609CPRI manuals

Owner’s manuals and user’s guides for Unknown Krystal Touch of NY DL3609CPRI.
We providing 1 pdf manuals Krystal Touch of NY DL3609CPRI for download free by document types: Installation Guide


Table of contents





More products and manuals for Unknown Krystal Touch of NY

Models Document Type
DL3733ABPAS Installation Guide   Krystal Touch of NY DL3733ABPAS Installation Guide, 1 pages
DL3802BPRI Installation Guide   Krystal Touch of NY DL3802BPRI Installation Guide, 1 pages
DL3611CPAS Installation Guide   Krystal Touch of NY DL3611CPAS Installation Guide, 1 pages
DL3616BPAS Installation Guide   Krystal Touch of NY DL3616BPAS Installation Guide, 1 pages
DL3616CPAS Installation Guide   Krystal Touch of NY DL3616CPAS Installation Guide, 1 pages