global variable declaration

sarathbabu
2012-10-22
2012-10-24
  • sarathbabu - 2012-10-22

    Hi is this declaration possible

              var_global
              posoffset:=4800*2;
              end_var
    
     
  • Rolf-Geisler - 2012-10-23

    Hi,
    it is not.

    First of all you have to declare the data type:

    VAR_GLOBAL
    Β  Β  posoffset : INT;
    END_VAR
    

    Then you can add an initialization value

    VAR_GLOBAL
    Β  Β  posoffset : INT := 9600;
    END_VAR
    

    I'm afraid, calculations are not possible in these declarations.

     
  • sarathbabu - 2012-10-24

    Yes I tried and ended up with errors

    Thanks

     
  • singleton - 2012-10-24

    In V3.x this kind of declaration is possible.

     
  • shooter - 2012-10-24

    a better solution is to use the following
    VAR_GLOBAL CONSTANT
    screen : INT := 4800;
    two:INT:=2;
    END_VAR

    and then use a calc in a initialise routine
    posoffset := screen*two;
    when the screen changes only one place needs changing.
    btw you have a variable when using visualisations.

     

Log in to post a comment.