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

Library and external variables

GUI
2019-02-13
2019-02-15
  • GUI - 2019-02-13

    Hello
    is it possible from a library to access an external variale (declared on the application, not on the library itself) ?

    on "C" programming it is used the "extern" keywork, to define a variable that is external to a library (and so linked later, when library and main application are put together)

     
  • dFx

    dFx - 2019-02-14

    You can link a variable from another Library.

    You can also define a pointer that should be initialized to point on that value.

     
  • GUI - 2019-02-14

    yes, for sure ... I can do it with a pointer but have to initialize it !
    I also already use variable from other library ....

    is it possible to do without a pointer ?

    I tried to use in the library
    VAR_EXTERN
    a: INT
    END_VAR

    and "a" is defined on the application
    It seemed something similar to "C" ... (extern int a) but it has not same intent ... it generate an error anyway.

    it would be good to have a sort of library that is just CODE ATTACHED to the main application, so with possibility to call any variable or function too.

     

Log in to post a comment.