|
|
|
|
|
|
|
|
|
|
|
|
foreach
|
|
|
Vera supports the foreach construct for single dimensional fixed-size arrays, dynamic arrays and SmartQs. Associative arrays, string mapped associative arrays and multi-dimensional arrays are not supported. |
|
|
|
|
|
Syntax : foreach |
|
|
|
|
|
foreach (name, loop_variable){
statements;
}
|
|
|
|
|
|
|
|
|
|
|
|
Example : foreach
|
|
|
|
|
|
1 program foreach_statement {
2 string magic[$] = {"ASIC","WORLD","DEEPAK","KUMAR", "TALA"};
3 integer i = 0;
4 foreach (magic,i) {
5 printf("String at index %0d is %s\n",i,magic[i]);
6 }
7 }
You could download file foreach_statement.vr here
|
|
|
|
|
|
Simulation : foreach
|
|
|
|
|
|
String at index 0 is ASIC
String at index 1 is WORLD
String at index 2 is DEEPAK
String at index 3 is KUMAR
String at index 4 is TALA
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Copyright © 1998-2014 |
Deepak Kumar Tala - All rights reserved |
Do you have any Comment? mail me at:deepak@asic-world.com
|
|