Indexing with variables - multidimensional arrays in GT Designer3 scripts

Indexing with variables - multidimensional arrays in GT Designer3 scripts

Info
This article describes how to index multidimensional arrays using variables in GT Designer3 scripts

Indexing an array with variables (e.g. testArray[ i , j , k ]) is achieved by applying an offset to the first element of the array

Dimension multipliers

   For a three-dimension array testArray[i, j, k] with the following sizes:
      First dimension size: a
      Second dimension size: b
      Third dimension size: c
            The multiplayer for the third dimension is 1
            The multiplayer for the second dimension is c
            The multiplayer for the first dimension is b*c
      Offset = 1*k + (c)*j + (b*c)*i

Practical example:
   For an array defined as newArray[0..16, 0..3, 0..7] and an index reference of newArray[i,j,k], the calculation uses the following dimension sizes:
      a = 17
      b = 4
      c = 8
    Offset = 1*k + 8*j + (4*8)*i


GT Designer3 project

To test this method, a sample three-dimensional array was mapped to devices starting at D200

First dimension: Index value stored in D0
Second dimension: Index value stored in D1
Third dimension: Index value stored in D2

The final offset, stored in D10, is determined by multiplying and summing the dimensions indices.

Alert
The value of D10 must be updated within a separate script
Alert
Multipliers 100, 10, 1 depend on the array dimensions.

With the offset value updated, the code can reference the array by its name (testArray) or via the associated start device (D200).

Notes
Example:
  testArray[ i , j , k ],  where i=2, j=7, k=4

  The offset (D10) is caculated as the sum of: 100*i + 10*j + 1*k
  D10 = 100*2 + 10*7 + 1*4 = 274

  testArray[0,0,0])[D10]  =>  testArray[0,0,0])[274]  =>  testArray[2,7,4] 




    • Related Articles

    • GT Designer3 ANDON function settings

      This is specification of ANDON function. The document describes how to set got mobile function, which is necessary to run ANDON function. In the next section connection ANDON with SQL Database is provided Summary: The ANDON function enables a ...
    • GOT1000 - Show and hide objects in a GOT HMI project

      Summary:  This document describes how to hide and show objects in GOT1000 depending on bit state. The solution is based on using object scripts  The solution of hiding and showing objects is presented step by step below: Introduction Under certain ...
    • Exchanging Labels - Navigator, GX Works3, GT Designer3

      This document shows the sample way for preparing label exchange between Mitsubishi PLC and HMI Navigator setting Building workspace Create new workspace. Initialize it with network configuration.   After this step, you can choose what is included to ...
    • Iconics Suite - GOT project conversion to GraphWorX64 screens

      Summary: this document describes how to convert existing GT designer project to Iconics GraphWorX files Launch GENESIS64 Converter-GOT from Windows Start > ICONICS Tools, specify your GTX project file and fill in a few other settings. The tool will ...
    • SLMP connection with robot. Sending global and status variables to SLMP Client

      FR series robot (CR 800 controllers) have additional option of SLMP communication server implemented as standard. This enables to obtain several data from robot controller without complex configuration. With additional configuration there is ...