Array elements are handled just like separate variables, i.e. a[0] is
just a variable with the name "a[0]".
In order to reference a variable by name, there is the 'var' action:
Juha Heinanen wrote on 11/24/2015 02:03 PM:
> is it possible to index dsm arrays using a variable? i have tried many
> variations without luck and could not find anything from the docs.
>
> set($a[0] = 1);
> set($a[1] = 2);
> for ($n in $a) {
> info("n is $n");
> };
>
> set($m = $a[0]);
> info("m is $m");
>
var($m1="a[0]");
info("m1 is $m1");
set($i = 0);
sets($v="a[$i]");
var($m=$v);
info("m is $m");
(Double quotes are not strictly necessary, that's possibly a question
of taste)
hth
Stefan
> set($i = 0);
> set($m = $a[$i]);
> info("m is $m");
>
> produces:
>
> Nov 24 14:58:53 lohi sems[21000]: [#7f5361f16700] [execute,
> DSMCoreModule.cpp:634] INFO: FSM: 'n is 1'
> Nov 24 14:58:53 lohi sems[21000]: [#7f5361f16700] [execute,
> DSMCoreModule.cpp:634] INFO: FSM: 'n is 2'
> Nov 24 14:58:53 lohi sems[21000]: [#7f5361f16700] [execute,
> DSMCoreModule.cpp:634] INFO: FSM: 'm is 1'
> Nov 24 14:58:53 lohi sems[21000]: [#7f5361f16700] [execute,
> DSMCoreModule.cpp:634] INFO: FSM: 'm is '
>
> how to write
>
> set($i = 0);
> set($m = $a[$i]);
>
> so that $m would contain value of $a[0]?
>
> -- juha
_______________________________________________
Sems mailing list
[email protected]
http://lists.iptel.org/mailman/listinfo/sems