Jump to content
Sign in to follow this  
demon cleaner

Array iteration

Recommended Posts

Hi !

I'm trying to apply certain code to every element of an array by using this forEach loop:

{ call compile format ["
   while {true} do {
       if (!(isNil ""%1"") && !(isNull %1)) then {
           ...
           <snip>omitted because of irrelevance</snip>
           ...
       };", (_x select 0), (_x select 2)];
       sleep 0.123;
   };
} forEach somePublicVariable;

For some reason it will only iterate to the first index, while this code bock here works just fine:

{ call compile format ["
   if (!(isNil ""%1"") && !(isNull %1)) then {
   ...
   <snip>omitted because of irrelevance</snip>
   ...
   };", (_x select 0), (_x select 2)];
   sleep 0.123;
} forEach somePublicVariable;

What's wrong with that while loop ? What am I missing here ? ... :confused:

I simply can't explain this to myself and any insight would be greatly appreciated.

Cheers !

DC

Share this post


Link to post
Share on other sites

DOH ! ... OK now that was stupid. Thank you !

I now see what you mean.

SOLVED

Edited by Demon Cleaner

Share this post


Link to post
Share on other sites

If that was me demon cleaner, i'd edit the first post to make the problem a bit harder ;)

Share this post


Link to post
Share on other sites

Yeah yeah go on bashing me...for that I deserve it ;) ... excuse me now I'll continue beating myself up for that :yay:

Edited by Demon Cleaner

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×