File: ctrl_repeat.ck

package info (click to toggle)
chuck 1.5.5.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 41,056 kB
  • sloc: cpp: 123,473; ansic: 35,893; javascript: 2,111; yacc: 609; makefile: 457; python: 174; perl: 86
file content (23 lines) | stat: -rw-r--r-- 559 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// a 'repeat' loop repeats for a fixed number of repetitions

// our counter
0 => int x;

// repeat a fixed number of times
repeat( 4 )
{
    x++;
}

// repeat x number of times (or what the value of x is when we first
// reach this loop...e.g., should be 4 in this instance)
repeat( x )
{
    // the repeat value 'x' is evaluated only once at the beginning
    // of the loop; even if 'x' is subsequently changed, it will not
    // alter the number of repetitions of the loop
    x++;
}

// verify where the counter ended up
if( x == 8 ) <<< "success" >>>;