473,753 Members | 7,291 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Associate array of arrays

Pardon my ignorance here...

I have created arrays such as:
var SDET_Lab130= new Array();
SDET_Lab130['SDET'] = new Array();
SDET_Lab130['SDET'][0] = [0,400,7,24431,2 5179,24919,1.09 ,base];
SDET_Lab130['SDET'][1] = [1,400,7,27729,2 8031,27877,0.34 ,11.87,rate
Improved];
SDET_Lab130['SDET'][2] = [0,450,7,24691,2 5194,24966,0.75 ,base];
SDET_Lab130['SDET'][3] = [1,450,7,27598,2 8090,27860,0.60 ,11.59,rate
Improved];
SDET_Lab130['SDET'][4] = [0,500,7,24725,2 5171,24967,0.74 ,base];
SDET_Lab130['SDET'][5] = [1,500,7,27556,2 7941,27795,0.52 ,11.32,rate
Improved];

Now first off is this legal? If so I am having trouble accessing the
elements of the array. Basically I have a function which takes in the
hash string, then I want to loop through using two nested loops to get
all the elements of all the arrays for a given hash string.

Seems that to go through an associative array you need a loop as such
first
for (i in uniqueID[selected]) {

I guess if that is the case how to I drill down further from here?

Thanks a lot in advance. Any help is greatly appreciated.
Marc

Feb 22 '07 #1
5 2207
On Feb 22, 3:03 pm, "M. Fisher" <mcfishe...@gma il.comwrote:
Pardon my ignorance here...

I have created arrays such as:
var SDET_Lab130= new Array();
SDET_Lab130['SDET'] = new Array();
SDET_Lab130['SDET'][0] = [0,400,7,24431,2 5179,24919,1.09 ,base];
SDET_Lab130['SDET'][1] = [1,400,7,27729,2 8031,27877,0.34 ,11.87,rate
Improved];
SDET_Lab130['SDET'][2] = [0,450,7,24691,2 5194,24966,0.75 ,base];
SDET_Lab130['SDET'][3] = [1,450,7,27598,2 8090,27860,0.60 ,11.59,rate
Improved];
SDET_Lab130['SDET'][4] = [0,500,7,24725,2 5171,24967,0.74 ,base];
SDET_Lab130['SDET'][5] = [1,500,7,27556,2 7941,27795,0.52 ,11.32,rate
Improved];

Now first off is this legal? If so I am having trouble accessing the
elements of the array. Basically I have a function which takes in the
hash string, then I want to loop through using two nested loops to get
all the elements of all the arrays for a given hash string.

Seems that to go through an associative array you need a loop as such
first
for (i in uniqueID[selected]) {

I guess if that is the case how to I drill down further from here?

Thanks a lot in advance. Any help is greatly appreciated.
Marc

I don't think this matters, but throw it in too. The arrays are
declared in data.js which I include in the html file. And the function
to loop through is in dynmodule.js also included in a different file,
so the data resides in a file outside of the one with the function.

Feb 22 '07 #2
On Feb 22, 2:03 pm, "M. Fisher" <mcfishe...@gma il.comwrote:
Pardon my ignorance here...

I have created arrays such as:
var SDET_Lab130= new Array();
SDET_Lab130['SDET'] = new Array();
SDET_Lab130['SDET'][0] = [0,400,7,24431,2 5179,24919,1.09 ,base];
SDET_Lab130['SDET'][1] = [1,400,7,27729,2 8031,27877,0.34 ,11.87,rate
Improved];
SDET_Lab130['SDET'][2] = [0,450,7,24691,2 5194,24966,0.75 ,base];
SDET_Lab130['SDET'][3] = [1,450,7,27598,2 8090,27860,0.60 ,11.59,rate
Improved];
SDET_Lab130['SDET'][4] = [0,500,7,24725,2 5171,24967,0.74 ,base];
SDET_Lab130['SDET'][5] = [1,500,7,27556,2 7941,27795,0.52 ,11.32,rate
Improved];

Now first off is this legal?
Yes, but this is better:

var SDET_Lab130 = {
'SDET' : [
[0,400,7,24431,2 5179,24919,1.09 ,base],
[1,400,7,27729,2 8031,27877,0.34 ,11.87,rateImpr oved],
[0,450,7,24691,2 5194,24966,0.75 ,base],
[1,450,7,27598,2 8090,27860,0.60 ,11.59,rateImpr oved],
[0,500,7,24725,2 5171,24967,0.74 ,base],
[1,500,7,27556,2 7941,27795,0.52 ,11.32,rateImpr oved]
]
};
If so I am having trouble accessing the
elements of the array. Basically I have a function which takes in the
hash string, then I want to loop through using two nested loops to get
all the elements of all the arrays for a given hash string.
Something like this?

var loopThrough = function (key) {
var arr = SDET_Lab130[key];
for ( var i = 0, l = arr.length; i < l; i ++ ) {
for ( var j = 0, ll = arr[i].length; j < ll; j ++ ) {
// send each number/value to doSomething
doSomething(arr[i][j]);
}
}
};

Or something like this?

var loopThrough = function () {
for ( var i in SDET_Lab130 ) {
for ( var j = 0, l = arr[i].length; j < l; j ++ ) {
// send each array of values to doSomething
doSomething(SDE T_Lab130[i][j]);
}
}
};

Seems that to go through an associative array you need a loop as such
first for (i in uniqueID[selected]) {
You'll probably be less confused if you stop using the term
"Associativ e array. In Javascript, there are Objects, and there are
Arrays. Arrays are numeric ordered lists; Objects are hash tables.
Arrays use [], Objects use {} (though Objects can use the myObj['key']
form, which is just there because Javascript likes to be confusing ;)
For/in is for Objects, and for/iterate is for arrays.
It's easiest and less confusing to use them for what they're for.

I don't think this matters, but throw it in too. The arrays are
declared in data.js which I include in the html file. And the function
to loop through is in dynmodule.js also included in a different file,
so the data resides in a file outside of the one with the function.
You're right--it doesn't matter. As long as data.js appears before
the code that uses the object, you should be fine.

Cheers :)
--
Isaac Z. Schlueter
http://isaacschlueter.com

Feb 22 '07 #3
Isaac Schlueter wrote:
On Feb 22, 2:03 pm, "M. Fisher" <mcfishe...@gma il.comwrote:
>>I have created arrays such as:
var SDET_Lab130= new Array();
SDET_Lab130['SDET'] = new Array();
SDET_Lab130['SDET'][0] = [0,400,7,24431,2 5179,24919,1.09 ,base]...
>>Now first off is this legal?

Yes, but this is better:

var SDET_Lab130 = {
'SDET' : [
[0,400,7,24431,2 5179,24919,1.09 ,base],
Unless base (the last entry in the array) is a variable, I would suggest
the following:

SDET_Lab130['SDET'][0] = [0,400,7,24431,2 5179,24919,1.09 ,"base"];

Mick

Feb 23 '07 #4
On Feb 22, 3:03 pm, "M. Fisher" <mcfishe...@gma il.comwrote:
Pardon my ignorance here...

I have created arrays such as:
var SDET_Lab130= new Array();
SDET_Lab130['SDET'] = new Array();
SDET_Lab130['SDET'][0] = [0,400,7,24431,2 5179,24919,1.09 ,base];
SDET_Lab130['SDET'][1] = [1,400,7,27729,2 8031,27877,0.34 ,11.87,rate
Improved];
SDET_Lab130['SDET'][2] = [0,450,7,24691,2 5194,24966,0.75 ,base];
SDET_Lab130['SDET'][3] = [1,450,7,27598,2 8090,27860,0.60 ,11.59,rate
Improved];
SDET_Lab130['SDET'][4] = [0,500,7,24725,2 5171,24967,0.74 ,base];
SDET_Lab130['SDET'][5] = [1,500,7,27556,2 7941,27795,0.52 ,11.32,rate
Improved];

Now first off is this legal? If so I am having trouble accessing the
elements of the array. Basically I have a function which takes in the
hash string, then I want to loop through using two nested loops to get
all the elements of all the arrays for a given hash string.

Seems that to go through an associative array you need a loop as such
first
for (i in uniqueID[selected]) {

I guess if that is the case how to I drill down further from here?

Thanks a lot in advance. Any help is greatly appreciated.
Marc

Thanks for the help so far. If I want to expand this would the correct
syntax be:
var SDET_Lab130 = {
'SDET_Load1' : [
[0,400,7,24431,2 5179,24919,1.09 ,base],
[1,400,7,27729,2 8031,27877,0.34 ,11.87,rateImpr oved],
[0,450,7,24691,2 5194,24966,0.75 ,base],
[1,450,7,27598,2 8090,27860,0.60 ,11.59,rateImpr oved],
[0,500,7,24725,2 5171,24967,0.74 ,base],
[1,500,7,27556,2 7941,27795,0.52 ,11.32,rateImpr oved]
],
'SDET_Load2' : [
[0,400,7,24431,2 5179,24919,1.09 ,base],
[1,400,7,27729,2 8031,27877,0.34 ,11.87,rateImpr oved],
[0,450,7,24691,2 5194,24966,0.75 ,base],
[1,450,7,27598,2 8090,27860,0.60 ,11.59,rateImpr oved],
[0,500,7,24725,2 5171,24967,0.74 ,base],
[1,500,7,27556,2 7941,27795,0.52 ,11.32,rateImpr oved]
],
...
};

I have tried this and inside my function now where I do
var arr = SDET_Lab130[key];
and then try to access the length for arr, I get the error no property
defined. Also I have 11 'Load' identifiers but doing
SDET_Lab130.len gth gives me 19, so I am guessing that means my syntax
I am using is not right. Sorry again for the ignorance.

Feb 23 '07 #5
On Feb 23, 11:33 am, "M. Fisher" <mcfishe...@gma il.comwrote:
On Feb 22, 3:03 pm, "M. Fisher" <mcfishe...@gma il.comwrote:
Pardon my ignorance here...
I have created arrays such as:
var SDET_Lab130= new Array();
SDET_Lab130['SDET'] = new Array();
SDET_Lab130['SDET'][0] = [0,400,7,24431,2 5179,24919,1.09 ,base];
SDET_Lab130['SDET'][1] = [1,400,7,27729,2 8031,27877,0.34 ,11.87,rate
Improved];
SDET_Lab130['SDET'][2] = [0,450,7,24691,2 5194,24966,0.75 ,base];
SDET_Lab130['SDET'][3] = [1,450,7,27598,2 8090,27860,0.60 ,11.59,rate
Improved];
SDET_Lab130['SDET'][4] = [0,500,7,24725,2 5171,24967,0.74 ,base];
SDET_Lab130['SDET'][5] = [1,500,7,27556,2 7941,27795,0.52 ,11.32,rate
Improved];
Now first off is this legal? If so I am having trouble accessing the
elements of the array. Basically I have a function which takes in the
hash string, then I want to loop through using two nested loops to get
all the elements of all the arrays for a given hash string.
Seems that to go through an associative array you need a loop as such
first
for (i in uniqueID[selected]) {
I guess if that is the case how to I drill down further from here?
Thanks a lot in advance. Any help is greatly appreciated.
Marc

Thanks for the help so far. If I want to expand this would the correct
syntax be:
var SDET_Lab130 = {
'SDET_Load1' : [
[0,400,7,24431,2 5179,24919,1.09 ,base],
[1,400,7,27729,2 8031,27877,0.34 ,11.87,rateImpr oved],
[0,450,7,24691,2 5194,24966,0.75 ,base],
[1,450,7,27598,2 8090,27860,0.60 ,11.59,rateImpr oved],
[0,500,7,24725,2 5171,24967,0.74 ,base],
[1,500,7,27556,2 7941,27795,0.52 ,11.32,rateImpr oved]
],
'SDET_Load2' : [
[0,400,7,24431,2 5179,24919,1.09 ,base],
[1,400,7,27729,2 8031,27877,0.34 ,11.87,rateImpr oved],
[0,450,7,24691,2 5194,24966,0.75 ,base],
[1,450,7,27598,2 8090,27860,0.60 ,11.59,rateImpr oved],
[0,500,7,24725,2 5171,24967,0.74 ,base],
[1,500,7,27556,2 7941,27795,0.52 ,11.32,rateImpr oved]
],
...

};

I have tried this and inside my function now where I do
var arr = SDET_Lab130[key];
and then try to access the length for arr, I get the error no property
defined. Also I have 11 'Load' identifiers but doing
SDET_Lab130.len gth gives me 19, so I am guessing that means my syntax
I am using is not right. Sorry again for the ignorance.
Sorry got this working now, compatibility issue in Mozilla was
actually causing my errors with insertRow and not feeding it -1.

Feb 23 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
13781
by: Robert Oschler | last post by:
With PHP 4, is there a way to convert an associative array to an object? For example, suppose I have the following arrays inside a nested associative array ($nestedAA): $AA1 = 'fieldValue1'; $AA2 = 'fieldValue2'; $nestedAA = $AA1;
58
10174
by: jr | last post by:
Sorry for this very dumb question, but I've clearly got a long way to go! Can someone please help me pass an array into a function. Here's a starting point. void TheMainFunc() { // Body of code... TCHAR myArray; DoStuff(myArray);
21
3219
by: yeti349 | last post by:
Hi, I'm using the following code to retrieve data from an xml file and populate a javascript array. The data is then displayed in html table form. I would like to then be able to sort by each column. Once the array elements are split, what is the best way to sort them? Thank you. //populate data object with data from xml file. //Data is a comma delimited list of values var jsData = new Array(); jsData = {lib: "#field...
104
16999
by: Leszek | last post by:
Hi. Is it possible in javascript to operate on an array without knowing how mamy elements it has? What i want to do is sending an array to a script, and this script should add all values from that array Could you show me a little example how to do this? Thanks.
24
3456
by: Michael | last post by:
Hi, I am trying to pass a function an array of strings, but I am having trouble getting the indexing to index the strings rather than the individual characters of one of the strings. I have declared an array as: char *stringArray = {"one","two","three","a"}; When I pass the array using:
57
3257
by: buuuuuum | last post by:
why array can't be assigned, like structs?
17
7253
by: =?Utf-8?B?U2hhcm9u?= | last post by:
Hi Gurus, I need to transfer a jagged array of byte by reference to unmanaged function, The unmanaged code should changed the values of the array, and when the unmanaged function returns I need to show the array data to the end user. Can I do that? How?
1
3121
by: chiefychf | last post by:
I'm working on a school project and I am having a few issues... The program calls for three arrays a,b,c that have to be sorted, then compared to even or odd and stored in arrays d & e, then merge a,b,c into another array f.. I can do two arrays, but I have issues when trying to do all three and when I do the even/odd compare I only get 2 numbers processed. here is some of the code... //*******************Function...
2
1479
by: forrestarrow | last post by:
Hi everyone, I used STL map in my code and I am wondering is the associate data automatically initialized or not. The reason I am asking is that I have two arrays of data, and the first array is index, and second array is my data corresponding to the index. But there are duplicate indexs and I want to add up the data of duplicate index. For example; map<int index, double data> mid; mid += data; So I want to know at beginning, is the...
0
9072
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9653
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8328
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6869
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6151
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4771
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4942
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3395
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2872
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.