I hear you buddy, do what works for you and keeps you happy.
I'll take this opp to explain what the code snippet does however, line by line.
_phony = []
Tells OPF _phony is an array, we need it to know this for the next command
that resizes an array.
_phony resize 12
Makes room for 12 whatevers (the element type is unknown and irrelevant at this point) in our array _phony.
_units = []
Initialize a second array, _units, telling OPF it is an array. It needs to know this
when we start adding elements to it.
{"soldierWB" createUnit [getMarkerPos "mrk_x", test_grp, "foo=this"] ; _units = _units + [foo]} foreach _phony
We'll break this one up.
Syntax: "cmdstring..." foreach array
It will run "cmdstring..." for each element of array and replace _x in the command string
with the current element in the array. However, it doesnt require _x to exist in the command string, so foreach is of great use when you want to do something a couple of times without doing a loop (since making goto-loops in sqs:es gets boring quite quickly).
As you said earlier, { } and "" are inter-exchangable.
So, what we do is tell foreach we want to execute our command string 12 times, remember, _phony has the size of 12.
The commandstring is:
{"soldierWB" createUnit [getMarkerPos "mrk_x", test_grp, "foo=this"] ; _units = _units + [foo]}
Or split up even further:
"soldierWB" createUnit [getMarkerPos "mrk_x", test_grp, "foo=this"]
_units = _units + [foo]
The arguments to createUnit (the ones we use anyway) are:
[position, group, "init-string"]. GetMarkerPos.. and test_grp are self-explanatory.
As we want to keep track of the units we create, we assign 'this', which is always the unit that is being created in the init-string, to the temporary variable 'foo', just as you guessed.
Then we add that variable, or actually the value of it, which is the handle of the unit at this point, to our _units array. Thats the second line. (_units = _units + [foo]).
There is a great tutorial on arrays by snypir in the editing section - a must read.
And yeah, to extract the different unit handles from the array you'll use '_units select 0-11', you are right again.
Okidoki, I think that sums it up.
Good luck.