1// given a list of widgets, files, people, etc.
2longList = 10000;
3feedbackInterval = 100; // to be used as the modulus
4
5// loop over the list to process each item
6for( i=1; i <= longList; i++ ) {
7
8 // perform some operation
9
10 // mod operation gives feedback once every hundred loops
11 if( i % feedbackInterval == 0 ) {
12 percentCompleted = ( i / longList ) * 100;
13 writeOutput( "#percentCompleted# percent complete. " );
14 }
15
16}
17
1function minutesToHours( m ) {
2 hours = floor( m/60 );
3 minutes = m%60;
4
5 return "#hours# hours #minutes# minutes";
6}
7writeOutput( minutesToHours( 349 ) );
8
1// array of options that we want to cycle through
2weekdays = [ 'Mon', 'Tue', 'Wed', 'Thu', 'Fri' ];
3
4// option count provides modulus (divisor)
5dayCount = weekdays.len();
6
7employeeCount = 14;
8
9// loop over employees while rotating through days
10for( i=0; i < employeeCount; i++ ) {
11
12 // employee number mod option count
13 dayIndex = i % dayCount;
14 // adjust because CFML array indexed from 1
15 dayIndex++;
16 // use result to cycle through weekday array positions
17 weekday = weekdays[ dayIndex ];
18
19 writeOutput( "Scheduling employee on #weekday#. " );
20}
21