Warning: include(/var/www/html/forum/Sources/../../../includes/depot_files/OFPEC_get_header_image.inc.php): failed to open stream: No such file or directory in /var/www/html/forum/Sources/Load.php(2272) : eval()'d code on line 146

Warning: include(): Failed opening '/var/www/html/forum/Sources/../../../includes/depot_files/OFPEC_get_header_image.inc.php' for inclusion (include_path='.:/usr/local/lib/php') in /var/www/html/forum/Sources/Load.php(2272) : eval()'d code on line 146

Notice: Undefined index: OFPEC in /var/www/html/forum/Sources/Load.php(2272) : eval()'d code on line 152

Notice: Trying to access array offset on value of type null in /var/www/html/forum/Sources/Load.php(2272) : eval()'d code on line 152

Notice: Trying to access array offset on value of type null in /var/www/html/forum/Sources/Load.php(2272) : eval()'d code on line 152
    Home   Help Login Register  

Author Topic: Foreach in foreach  (Read 2101 times)

0 Members and 1 Guest are viewing this topic.

Offline Luke

  • Members
  • *
  • Thank God! The OFPEC Staff are here!
Foreach in foreach
« on: 29 Jun 2009, 23:35:10 »
Hey guys, is the following syntax right?

Code: [Select]
_array=_this select 0;
_script=_this select 1;

{
_crew = crew _x;
{[_y] execvm "_script"} foreach _crew;
} foreach _array;

Thanx, as always.

Luke
Pesky Human!!
Wort Wort Wort.

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Foreach in foreach
« Reply #1 on: 30 Jun 2009, 00:00:39 »
Inner loops of forEach will safely mask the value of _x from outer loops. Also, where you to pass the name of a script to your function, it would be passed directly to execVM, not passed as part of a string:
Code: [Select]
{
    _crew = crew _x; // _x refers to element of _array
    { [_x] execVM _script } foreach _crew; // _x refers to element of _crew
    hint str _x; // _x refers to element of _array
} foreach _array;
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)