FAQ Search
>   Select Language

For Integer Array, when accessing a bit

  After conversion from GP-Pro/PBIII to GP-Pro EX, two differences are made as described below.

1) Converted to a description with the number of elements specified.

Only the description changes. No work is necessary after conversion and the operation has no problem.
EX) For an array of integer variables, when the 250th bit is specified, 
Specified on GP-PRO/PBIII C-Package :IntegerArray.X[250]  

Display on GP-Pro EX :                          IntegerArray[7].X[26]  
                                                       The number of elements

For GP-PRO/PBIII, a bit can be directly specified without the number of elements specified. For GP-Pro EX, the same type of description is not retained. After conversion to GP-Pro EX, the description is converted to one with the number of elements automatically specified.

An integer variable is 32-bit.
250 divided by 32 is "7 and the remainder is 26".

The 250th bit of the integer variable of [Integer Array] is recognized as the 26th bit in the element 7 of [Integer Array] and it's displayed as Integer Array[7].X[26] on GP-Pro EX. 

2) If a bit position is indirectly specified with a variable, an error will occur.
EX) IntegerArray.X[IntegerVariableA]
  A bit position is specified with a variable

This type of variables cannot be converted for GP-Pro EX and an error occurs.
Make some changes following the steps below.
  1. Delete the integer variable that is a source of the error (EX: [Integer Array.X[250]) from the logic program on GP-PRO/PBIII.
  2. Change the logic program on GP-PRO/PBIII as shown below. 

    Change the type to the one that specifies the number of elements like [Integer Array.X[250]] is changed to [Integer Array[7].X[26]].
    Divide the variable for bit set, [Integer VariableA] by 32 to calculate the number of elements and specify it with a variable.
    And specify [the remainder] that shows a bit position with a variable. 

     How to change a logic program 
  3. Perform [Convert] on GP-Pro EX.

■How to change a logic program
  1. Using the DIV (division operation) instruction, divide [Integer VariableA] by 32 and assign the result to the newly created [Integer VariableB]. Use the value assigned to [Integer VariableB] as Element Number Set of [Integer Array] variables.

  2. The [remainder] of the calculation result after dividing [Integer VariableA] by 32 is Bit Position Set in an element. 
    Using the MOD (remainder operation) instruction, calculate a remainder and assign the result to the newly created [Integer VariableC]. Use the value assigned to [Integer VariableC] as Bit Set.

  3. Use Element Number Set ([Integer VariableB]) and Bit Position Set ([Integer VariableC]) that have been created in 1 and 2 instead of [Integer Array.X[Integer VariableA]] and output them with the retained and specified OUT (Out Coil) instruction.

    [Integer Array.X[Integer VariableA]] is changed to an integer array [Integer VariableB].X[Integer VariableC]and it can be used without causing an error even after conversion to GP-Pro EX.

FA227854  |  23-Apr-2015  | Technical Guides
Was this helpful?
What can we do to improve the information ?