SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 466 | Next

Steve Seguis

"Microsoft Windows Server 2008 Administration"


The For statement, otherwise known as a For loop, runs a block of code until a condition
is found to be true. Normally, you would use a For loop when you want to initialize
a variable, run it while the condition is true, and then run some code that is repeated
for each execution. FOR loops have the following syntax:
For(;;) {

}
The following code snippet is a For loop that counts from 1 to 100:
For($i=1;$i -lt 101;$i++) {
write-host $i
}
The section is executed only once for the For loop and is used for initialization.
In this example, I used this section to initialize $i to the value of 1. The
section defines what condition must be true before the code in the code block gets executed.
In this example, I state that if $i is less than 101, it can execute the code. The section
is code that is executed each time the loop executes. In this case, I increment $i by 1 by
using the shorthand notation of $i++, which is functionally equivalent to $i = $i + 1. Finally,
for each iteration of the loop, I output the value of $i. This effectively makes the script count
from 1 to 100 since once $i is incremented to the value of 101, the condition that $i is less
than 101 is no longer true and the loop stops executing.
NOTE If you have a programming background or have used C, C++, or Java, the ++ operator
should be nothing new to you.


Pages:
454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6