[DGD]Mappings with array indices
Paul Belemjian
belemp at rpi.edu
Sun Jan 21 18:12:42 CET 2001
I was trying to create some mappings that used arrays as their indices,
and have met with some limited success. The code I'm using to test it
is below.
void do_stuff()
{
mapping foobar;
mixed *stuff;
int *bar;
int i;
foobar = ([]);
bar = ({ 0, 0 });
foobar[ bar ] = 1;
foobar[ ({ 0, 1 }) ] = 2;
stuff = map_indices( foobar );
for( i = 0; i < sizeof(stuff); i++ )
{
this_user()->message( stuff[i][0] + ",");
this_user()->message( stuff[i][1] + "\n");
this_user()->message( foobar[stuff[i]] + "\n");
}
this_user()->message( foobar[bar] + "\n" );
this_user()->message( foobar[ ({ 0, 1 }) ] + "\n" );
}
The results are this: All of the statements in the for loop work and
print out the correct results.
The second to last line also works and prints out the correct value.
The last line doesn't work and returns an error (Value is not a string).
My question is if there is any way I can get the last line to work as
written, without having to make a variable and assign the value to that
first.
Paul Belemjian
List config page: http://list.imaginary.com/mailman/listinfo/dgd
More information about the DGD
mailing list