Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
what do they do?...
Apjjm Offline
Is easy to say

Posts: 496
Threads: 18
Joined: Apr 2011
Reputation: 52
#5
RE: what do they do?...

(int i=0;i<10;i++)

If we label each part of the for loop construct
for(A;B;C)
  {
   D
  }

A: Executed when the for loop is first run. This part is mostly used to define a counting variable (usually i - chosen as it is the first letter of iteration), anything declared here only exists for the looped code and the loop construct.
B: A condition. Whilst this condition is true, the for loop will run. This is mostly used to check if our counting variable meets a condition.
C: A statement which is executed after each iteration of the loop.
D: The code you want to loop

This can be used for standard counting, as above, but it can also be used in other ways too:
for(;i>0;)  //Doing nothing at the stages is permitted
for(int x=2; y<0; y+=x) //Having different variables is permitted
for(int i=1; GetEntityExists("scriptarea_"+i); i++) //Functions can be called.

For switch-case stuff, i recommend reading the angelscript documentation on the matter:
http://www.angelcode.com/angelscript/sdk...ts.html#if
it explains it very neatly.
(This post was last modified: 06-21-2011, 07:54 PM by Apjjm.)
06-21-2011, 05:46 PM
Find


Messages In This Thread
what do they do?... - by X4anco - 06-21-2011, 04:51 PM
RE: what do they do?... - by palistov - 06-21-2011, 04:55 PM
RE: what do they do?... - by X4anco - 06-21-2011, 04:56 PM
RE: what do they do?... - by palistov - 06-21-2011, 05:02 PM
RE: what do they do?... - by Apjjm - 06-21-2011, 05:46 PM
RE: what do they do?... - by palistov - 06-21-2011, 05:53 PM
RE: what do they do?... - by Apjjm - 06-21-2011, 06:09 PM
RE: what do they do?... - by palistov - 06-21-2011, 06:14 PM
RE: what do they do?... - by xiphirx - 06-21-2011, 06:57 PM



Users browsing this thread: 1 Guest(s)