473,385 Members | 1,320 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Array maddness programmer on the verge of a breakdown

34
Ok I hope someone can help me. My first array looks like this
array1 = (Section A, Section E,undefined,undefined,undefined,undefined,undefine d,undefined)
and my second 1 looks like this array 2 =( Section A, Section B, Section C, Section D, Section E,2. GRCM,3. ASPEN,4. R1)

I need to place Section A in my first array in position [0] and in position [4]. Can this be done by using the information from the second array. Please please can sonebody help me
Nov 7 '07 #1
6 1393
rsdev
149 100+
Ok I hope someone can help me. My first array looks like this
array1 = (Section A, Section E,undefined,undefined,undefined,undefined,undefine d,undefined)
and my second 1 looks like this array 2 =( Section A, Section B, Section C, Section D, Section E,2. GRCM,3. ASPEN,4. R1)

I need to place Section A in my first array in position [0] and in position [4]. Can this be done by using the information from the second array. Please please can sonebody help me
Is this in AS Flash?
Nov 7 '07 #2
Zarwadi
34
Is this in AS Flash?
Yes it is as flash file. ireall hope you can help me
Zar
Nov 8 '07 #3
rsdev
149 100+
Not sure what your trying to acheive but if you use Array.splice you can insert values into an array at a given position.

Take a look here for more info.

http://www.adobe.com/support/flash/action_scripts/actionscript_dictionary/actionscript_dictionary070.html

Hope this helps!
Nov 8 '07 #4
Zarwadi
34
Thanks for that but I know it does not do what I want.
I have not explained myself properly.
I's like this I have one array that looks like this
(Section D,Section A,undefined,undefined,undefined,undefined,undefine d,undefined)

and another array looks like this (Section A,Section B,Section C,Section D,Section E,2. GRCM,3. ASPEN,4. R1)

I need to find where Section D and Section A are in the second array. ie Section A = 0 and Section D = 3
I hope this makes sense
Nov 12 '07 #5
rsdev
149 100+
Are you trying to make a recursive method that uses the values in the first array to find the position of values in the second array?

Here is an example model of the top of my head (untested);

Expand|Select|Wrap|Line Numbers
  1. var array3:Array = new Array();
  2. var t;
  3. for(var i=0; i<array1.length; i++){
  4.     t = firstArray(array1, array2)
  5.     if(t>0){
  6.          array3.push(t);
  7.     }
  8. }
  9.  
  10. function firstArray(array1:Array, array2:Array):Number{
  11.       var l = array1.length;
  12.       for(var i=0; i<l; i++){
  13.           if(array1[i] == secondArray(array2, array1[i])){
  14.                return i;
  15.           } else {
  16.                 return 0;
  17.           }
  18.        }
  19. }
  20.  
  21. function secondArray(array2:Array, arrayObject:Object):Object{
  22.      var l = array2.length;
  23.      for(var i=0; i<l; i++){
  24.            if(array2[i] == arrayObject){
  25.                 return array2[i];
  26.            }
  27.      }
  28. }
  29.  
Not sure if this will work but should get you started.
Nov 13 '07 #6
Zarwadi
34
Thanks
for your help

Are you trying to make a recursive method that uses the values in the first array to find the position of values in the second array?

Here is an example model of the top of my head (untested);

Expand|Select|Wrap|Line Numbers
  1. var array3:Array = new Array();
  2. var t;
  3. for(var i=0; i<array1.length; i++){
  4.     t = firstArray(array1, array2)
  5.     if(t>0){
  6.          array3.push(t);
  7.     }
  8. }
  9.  
  10. function firstArray(array1:Array, array2:Array):Number{
  11.       var l = array1.length;
  12.       for(var i=0; i<l; i++){
  13.           if(array1[i] == secondArray(array2, array1[i])){
  14.                return i;
  15.           } else {
  16.                 return 0;
  17.           }
  18.        }
  19. }
  20.  
  21. function secondArray(array2:Array, arrayObject:Object):Object{
  22.      var l = array2.length;
  23.      for(var i=0; i<l; i++){
  24.            if(array2[i] == arrayObject){
  25.                 return array2[i];
  26.            }
  27.      }
  28. }
  29.  
Not sure if this will work but should get you started.
Jan 9 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

58
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...
22
by: Wynand Winterbach | last post by:
I think every C programmer can relate to the frustrations that malloc allocated arrays bring. In particular, I've always found the fact that the size of an array must be stored separately to be a...
0
by: BuddyWork | last post by:
Hello, I want to know if there any good tools out there which will show me a breakdown of the memory allocation in Gen 2 heap, basically a breakdown by object is what I'm looking for. The...
104
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...
272
by: Peter Olcott | last post by:
http://groups.google.com/group/comp.lang.c++/msg/a9092f0f6c9bf13a I think that the operator() member function does not work correctly, does anyone else know how to make a template for making two...
11
by: Tim Hunter | last post by:
Hi I am using WinXP and Access 2003 Is it possible to store the field names of a table in an array and then loop through the array and update the table using the field names stored in the array? I...
7
by: theballz | last post by:
Hi, I am learning c programming and come across a problem i cant seem to solve. I have a file which i wish to parse and put certain lines (which do not contain a hash character) into an array...
3
by: Daron | last post by:
Is it possible to use SQL to take a field, and break it down by denominations? I would like to take a field, and then break this out into the number of bills($100's, $50's, etc) I would need:...
6
by: rbutlerjr | last post by:
Hi, I've racked my brain for the last few hours trying to figure this one out. I have an array of language strings such as : $lang = array(); $lang = 'hello'; $lang = 'goodbye'; $lang = '1st';...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.