diff options
Diffstat (limited to 'src/3rdparty/squirrel/samples/loops.nut')
-rw-r--r-- | src/3rdparty/squirrel/samples/loops.nut | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/3rdparty/squirrel/samples/loops.nut b/src/3rdparty/squirrel/samples/loops.nut new file mode 100644 index 000000000..50074c935 --- /dev/null +++ b/src/3rdparty/squirrel/samples/loops.nut @@ -0,0 +1,32 @@ +local arr=["one","two","three"] + +::print("FOREACH\n"); + +foreach(i,val in arr) +{ + ::print("index ["+i+"]="+val+"\n"); +} + +::print("FOR\n"); + +for(local i=0;i<arr.len();i+=1) +{ + ::print("index ["+i+"]="+arr[i]+"\n"); +} + +::print("WHILE\n"); + +local i=0; +while(i<arr.len()) +{ + ::print("index ["+i+"]="+arr[i]+"\n"); + i+=1; +} +::print("DO WHILE\n"); + +local i=0; +do +{ + ::print("index ["+i+"]="+arr[i]+"\n"); + i+=1; +}while(i<arr.len()); |