Skip to content
  • There are no suggestions because the search field is empty.

How can I create a 2D array through DataHub scripting?

How can I create a 2D array though a script using the DataHub?

Below is a sample of the code.  Attached is the full script.

Running the Script

Go to the Scripting section in the DataHub.  Then click Add and the script.  Then you can highlight the script and click Load Now to load the script once.  Or you can check the box next to it and click apply to make it run on every start up and then restart the DataHub to load the script.

     //CREATE AND INITIALIZE BOTH 1D ARRAYS
     local myArray1 = array();
     local myArray2 = array();
     myArray1[0] = 1;
     myArray1[1] = 2;
     myArray2[0] = 3;
     myArray2[1] = 4;

     //INITIALIZE THE 2D ARRAY FROM THE FIRST TWO     
     local my2dArray = array(myArray1, myArray2);
     
     //PRINT THE ENTIRE ARRAY AND EACH ELEMENT
     princ("Full Array - ", my2dArray, "\n");
     princ("Element 0,0 - ", my2dArray[0][0], "\n");
     princ("Element 0,1 - ", my2dArray[0][1], "\n");
     princ("Element 1,0 - ", my2dArray[1][0], "\n");
     princ("Element 1,1 - ", my2dArray[1][1], "\n");