|
|
Quellcode |
1 2 3 4 5 |
<enum name="floors">
<item name="floor_1" data="mydata" />
<item name="floor_2" data="mydata" />
<item name="floor_3" data="mydata" />
</enum>
|
|
|
Quellcode |
1 |
trace(enum[floors].item[0].name, " has as data: ", enum[floors].item[0].data); |
|
|
Quellcode |
1 |
trace(a.name, " has as data: ", a.data); |
|
|
Quellcode |
1 |
copy(a, enum[floors].item[0]); |
|
|
Quellcode |
1 |
copy(a.content, enum[floors].item[0].content); |
I have tried this:
Zitat
Is there any way to accomplish this? I tried:This will make a.name available, but not a.data.
![]()
Quellcode
1 copy(a, enum[floors].item[0]);
|
|
Quellcode |
1 2 3 |
trace(enum[floors].item[0].name, " has as data: ", enum[floors].item[0].data); copy(a, enum[floors].item[0]); trace(a.name, " has as data: ", a.data ); |
|
|
Quellcode |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
<!--
foreach ( <object>, <loop variable>, <object variable> <command(s)> );
"foreach" loop function executes a command string for each child of the given object.
Example: foreach(enum[floors].item, i, a, trace("#", i, ': ', a.name, " has as data: ", a.data);";);
This will execute the given trace command as many times as there are "item" nodes in the
<enum name="floors"> object. As we passed "a" as object variable, we can use the same "a"
in our command string to represents the child object itself, instead of having to use
enum[floors].item[get(i)].
Sample data format for the above example:
<enum name="floors">
<item name="floor_1" data="mydata" />
<item name="floor_2" data="mydata" />
<item name="floor_3" data="mydata" />
</enum>
-->
<action name="foreach">
_foreach_for(
set(%2,0),
%2 LT %1.count,
inc(%2),
%4,
copy(%3, %1[get(i)]);
);
</action>
<action name="_foreach_for">
push(action[_foreach_action].content);
set(action[_foreach_action].content, "%1;");
_foreach_action();
set(action[_foreach_action].content, "%5; if(%2, %4; %3; _foreach_action(););");
_foreach_action();
pop(action[_foreach_action].content);
</action>
<action name="_foreach_action">
trace("Error in foreach loop: push/pop stack corrupted"); <!-- this line should never execute -->
</action>
|
|
|
Quellcode |
1 2 3 |
<action name="test">
foreach(enum[floors].item, i, a, trace("#", i, " is ", a.name, " and has as data: ", a.data ); );
</action>
|
Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »rdhoore108« (12. September 2010, 14:30)
|
|
Quellcode |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
<!--
foreach ( <object>, <loop variable>, <object variable> <command(s)> );
"foreach" loop function executes a command string for each child of the given object.
Example: foreach(enum[floors].item, i, a, trace("#", i, ': ', a.name, " has as data: ", a.data);";);
This will execute the given trace command as many times as there are "item" nodes in the
<enum name="floors"> object. As we passed "a" as object variable, we can use the same "a"
in our command string to represents the child object itself, instead of having to use
enum[floors].item[get(i)].
Sample data format for the above example:
<enum name="floors">
<item name="floor_1" data="mydata" />
<item name="floor_2" data="mydata" />
<item name="floor_3" data="mydata" />
</enum>
-->
<action name="foreach">
set(%2,0);
push(action[_foreach_action].content);
set(action[_foreach_action].content, "
copy(%3, %1[get(%2)]);
if(%2 LT %1.count,
%4;
copy(%1[get(%2)], %3);
inc(%2);
_foreach_action();
);
");
_foreach_action();
pop(action[_foreach_action].content);
</action>
<action name="_foreach_action">
trace("Error in for loop: push/pop stack corrupted"); <!-- this line should never execute -->
</action>
|
Dieser Beitrag wurde bereits 3 mal editiert, zuletzt von »rdhoore108« (18. September 2010, 10:07)