Re: Associative with MultiDimensional arrays



On 12 Sep 2006 09:38:57 -0700, "VK" <schools_ring@xxxxxxxxx> wrote:

Aziz wrote:
profiles["p1"][0] = new profileRecord(10, 20, 30);
profiles["p1"][1] = new profileRecord(10, 20, 30);
profiles["p1"][2] = new profileRecord(10, 20, 30);
<snip>
alert(profiles["p1"][0].x);

is effectively
undefined[0] = new profileRecord(10, 20, 30);
alert(undefined[0].x)
this makes the problem more visual.

I expect "10" would be displayed but instead I get the error that
profiles.p1 doesn't exist. How can I correct it?

function showVal()
{
alert(profiles[1].x);
}

function profileRecord(x, y, z)
{
this.x = x;
this.y = y;
this.z = z;
}

var profiles = new Array(3);

profiles[0] = new profileRecord(10, 20, 30);
profiles[1] = new profileRecord(10, 20, 30);
profiles[2] = new profileRecord(10, 20, 30);

Thanks but what you suggest is a 2 dimensional array, while I try to
implement a 3 dimensional array with the first index as a string. Is
it not possible?
.



Relevant Pages

  • Re: How do copy Strings from a single dimensional array to double dimensional array
    ... >>I need to copy strings from a single dimensional array to a double ... get a particular string and than need to store them. ... Table Capitals ... // Assuming this Code will take the file pointer to the location where Table ...
    (comp.lang.cpp)
  • Re: how to read letters
    ... than spaces and dots and comma in a ONE dimensional array ... first i switch to data string, so i don't think i have to worry about ... and then i only reads Captial letters A ...
    (comp.lang.java.help)
  • Re: Quickest way to find the string in 1 dimensional string array!
    ... Rather than a 1 dimensional array you should probably be storing your ... strings in a hashtable using the generated hash of the string as the key. ... Find great Windows Forms articles in Windows Forms Tips and Tricks ... > Dim queueAs String ...
    (microsoft.public.dotnet.languages.csharp)
  • 2 dimensional array-->1 dimensional array
    ... Let's say I have a 2 dimensional array: ... Dim arrSAs String ... I want to copy the subarray arrSto a new array arrLoopAs ... at the end of the process, I want to know which parameter order was ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Using an array as a Class member
    ... dimensional array = string[] ... reference to the array on the heap. ...
    (microsoft.public.dotnet.languages.csharp)