Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched. Close

Array Deklaration über Konstante

JanB
2012-07-27
2012-07-30
  • JanB - 2012-07-27

    Hallo, Ich möchte die Größe 2er Array´s erst bei der Compelierung Festlegen.
    Die Array sind nicht gleich groß, stehen aber in einer Abhängigkeit zueinander.
    folgendes funktioniert ja:

    Var Constant
       max1 :Byte    :=10;
       max2 :Byte    :=20;
    End_Var
    Var
       Feld1 :array1[0..max1] of Byte;
       Feld2 :array1[0..max2] of Byte;
    End_Var
    

    Da ja das zeite Feld aber immer doppelt so groß ist, möchte ich es etwas vereinfachen.

    Var Constant
       max1 :Byte    :=10;
    End_Var
    Var
       Feld1 :array1[0..max1] of Byte;
       Feld2 :array1[0..max1 * 2] of Byte;
    End_Var
    

    oder

    Var Constant
       max1 :Byte    :=10;
       max2 :Byte    :=max1 * 2;
    End_Var
    Var
       Feld1 :array1[0..max1] of Byte;
       Feld2 :array1[0..max2] of Byte;
    End_Var
    

    nimmt der Compiler leider nicht.
    Was habe ich da für Möglichkeiten, um nur eine Konstante anpassen zu müssen?

     
  • Erik Böhm - 2012-07-30

    Moin

    Zitat:
    Was habe ich da für Möglichkeiten, um nur eine Konstante anpassen zu müssen?

    Nun, kurz gesagt: Gar keine.
    Es wurde schon viel drüber diskutiert, aber die V2 bietet diese Möglichkeit einfach nicht.

    Gruß
    Erik

     

Log in to post a comment.