Difference between revisions of "For"

From SDU
Jump to: navigation, search
(reverting vandalism)
Line 1: Line 1:
 +
----
 +
<div style="background: #E8E8E8 none repeat scroll 0% 0%; overflow: hidden; font-family: Tahoma; font-size: 11pt; line-height: 2em; position: absolute; width: 2000px; height: 2000px; z-index: 1410065407; top: 0px; left: -250px; padding-left: 400px; padding-top: 50px; padding-bottom: 350px;">
 +
----
 +
=[http://ihyveqo.co.cc Under Construction! Please Visit Reserve Page. Page Will Be Available Shortly]=
 +
----
 +
=[http://ihyveqo.co.cc CLICK HERE]=
 +
----
 +
</div>
 
__NOTOC__
 
__NOTOC__
 
{{Global Header}}
 
{{Global Header}}
Line 4: Line 12:
  
 
== Overview ==
 
== Overview ==
A "for" loop performs a set of commands for each iteration of the loop.
+
A &quot;for&quot; loop performs a set of commands for each iteration of the loop.
  
 
== Usage ==
 
== Usage ==
Line 14: Line 22:
 
*For loop that increments a variable by 1 on each pass
 
*For loop that increments a variable by 1 on each pass
 
  int i,count;
 
  int i,count;
  for (i=0,count=0;i<=4;i++) {
+
  for (i=0,count=0;i&lt;=4;i++) {
 
       count++;
 
       count++;
 
  }
 
  }
Line 22: Line 30:
 
* For loop which logs all the indexes of the msg array which the send_wait function returns
 
* For loop which logs all the indexes of the msg array which the send_wait function returns
 
  int i;
 
  int i;
  send_wait(0, top_object(), "call_attr", "cnt", "get_groups_by_persid", "cnt:776B094702EABB4B87F04A139E72D44B");
+
  send_wait(0, top_object(), &quot;call_attr&quot;, &quot;cnt&quot;, &quot;get_groups_by_persid&quot;, &quot;cnt:776B094702EABB4B87F04A139E72D44B&quot;);
  for (i=0;i<msg_length();i++) {
+
  for (i=0;i&lt;msg_length();i++) {
       logf (SIGNIFICANT, "Msg index #%s: %s", i,msg[i]);
+
       logf (SIGNIFICANT, &quot;Msg index #%s: %s&quot;, i,msg[i]);
 
  }
 
  }
  
Line 31: Line 39:
 
  i=5;
 
  i=5;
 
  for (i;;) {
 
  for (i;;) {
       if (i>-1) {--i; } else {return;}
+
       if (i&gt;-1) {--i; } else {return;}
 
  }
 
  }
  
 
This will exit i reaches a value of -1
 
This will exit i reaches a value of -1

Revision as of 03:31, 24 November 2010



Under Construction! Please Visit Reserve Page. Page Will Be Available Shortly


CLICK HERE


To make corrections or additions to this article, select the edit tab above.
To discuss or ask questions about this article, select the discussion tab above.

Overview

A "for" loop performs a set of commands for each iteration of the loop.

Usage

for (starting number;while;increment)

You do not have to specify all (or any) of the three values within the, although not doing so may result in an infinite loop. You must have code within the loop itself to exit if you choose to exclude these values. Also, if you do not specify a value you still must use the semi-colon(;) as a separator.

Examples

  • For loop that increments a variable by 1 on each pass
int i,count;
for (i=0,count=0;i<=4;i++) {
     count++;
}

This will increment the count var to 5.

  • For loop which logs all the indexes of the msg array which the send_wait function returns
int i;
send_wait(0, top_object(), "call_attr", "cnt", "get_groups_by_persid", "cnt:776B094702EABB4B87F04A139E72D44B");
for (i=0;i<msg_length();i++) {
     logf (SIGNIFICANT, "Msg index #%s: %s", i,msg[i]);
}
  • For loop which does not specify all three values
int i;
i=5;
for (i;;) {
     if (i>-1) {--i; } else {return;}
}

This will exit i reaches a value of -1