Announcement

Collapse
No announcement yet.

Need a 4 dimensional array, is this how you do it?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Need a 4 dimensional array, is this how you do it?

    I found examples of arrays in 2 dimensions but not more. Is this how you would write a 4 dimensional array? I undertand arrays in QuickBasic, but am having troubles with EFS.

    PHP Code:
    = new Array(16)
    = new Array(8)
    = new Array(20)
    = new Array(5)
    var 
    lCount 0;

    function 
    main() {
        for (var 
    iii 0iii 16iii++) {
            
    a[iii] = new Array(4)
            for (var 
    jjj 0jjj 16jjj jjj 2) {
                
    b[iii][jjj] = new Array(4)
                for (var 
    kkk 50kkk 90kkk kkk 2) {
                    
    c[iii][jjj][kkk] = new Array(4)
                    for (var 
    lll 1lll 6lll++) {
                        
    d[iii][jjj][kkk][lll] = new Array(4)
                        
    lCount lCount 1;
                        
    d[iii][jjj][kkk][1] = lCount
                        d
    [iii][jjj][kkk][2] = close(0)
                        
    d[iii][jjj][kkk][3] = close(0) / lCount
                        d
    [iii][jjj][kkk][4] = close(-3) / lCount
                        d
    [iii][jjj][kkk][5] = close(0) / close(-3)
                    }    
                }    
            }
        }


  • #2
    Figured it out but arrays are "undefined", why?

    OK, I think I figured out how to do a four dimensional array, is this correct?

    When I run it, all the arrays initially are set to zero (notated with //Note 1) when makeItHappen is set to "false". However, the next time it comes around, makeItHappen is now set to "true", and it says the array (notated with //Note 2) is "NaN" (the arays are "undefined"). Why is this? It says it is zero the first time, but the second, third, fourth, etc. time it is NaN. Can anyone tell me what I am doing wrong?

    PHP Code:
    makeItHappen false;

    function 
    main() {
        var 
    ibarMinute getMinute(0);
        var 
    ibarHour getHour(0);

        if (
    ibarHour == 15 && ibarMinute == 59) {
            for (var 
    iii 0iii 16iii++) {
                
    aArray = new Array()   
                for (var 
    jj 0jj 16jj jj 2) {
                    
    aArray[iii] = new Array() 
                    for (var 
    kk 50kk 99kk kk 2) {
                        
    aArray[iii][jj] = new Array() 
                        for (var 
    lll 1lll 6lll++) {
                            
    aArray[iii][jj][kk] = new Array()    
                            if (
    makeItHappen == false) {
                                
    aArray[iii][jj][kk][lll] = 0    //Note 1
                            
    }
                        }
                        if (
    makeItHappen == true) {
                            
    aArray[iii][jj][kk][1] = aArray[iii][jj][kk][1] + 1   //Note 2
                        
    }    
                    }
                }    
            }
        
    makeItHappen true;
        }
    return;

    Comment


    • #3
      Hi
      Im having the same issue. Have you found out how to create a 3 dimensional array and call the data?

      Would appreciate your help.
      below is the 2 dimensional array..ive tried alot of changes but still unable to get it working. Please any kind of help would be much appreciatred


      myVar="Multidimensional array test; "
      a = new Array(4)
      for (i=0; i < 4; i++) {
      a[i] = new Array(4)
      for (j=0; j < 4; j++) {
      a[i][j] = "["+i+","+j+"]"
      }
      }
      for (i=0; i < 4; i++) {
      str = "Row "+i+":"
      for (j=0; j < 4; j++) {
      str += a[i][j]
      }
      myVar += str +"; "
      }

      Comment


      • #4
        Hi
        Im having the same issue. Have you found out how to create a 3 dimensional array and call the data?

        Would appreciate your help.
        below is the 2 dimensional array..ive tried alot of changes but still unable to get it working. Please any kind of help would be much appreciatred


        myVar="Multidimensional array test; "
        a = new Array(4)
        for (i=0; i < 4; i++) {
        a[i] = new Array(4)
        for (j=0; j < 4; j++) {
        a[i][j] = "["+i+","+j+"]"
        }
        }
        for (i=0; i < 4; i++) {
        str = "Row "+i+":"
        for (j=0; j < 4; j++) {
        str += a[i][j]
        }
        myVar += str +"; "
        }

        Comment

        Working...
        X