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)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
That said, as long as you declare your variables in a global variable list (in your Library), you should be able to access it from your program (if they are public).
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)
You can link a variable from another Library.
You can also define a pointer that should be initialized to point on that value.
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.
That said, as long as you declare your variables in a global variable list (in your Library), you should be able to access it from your program (if they are public).
May be you are looking for VAR_EXTERNAL declaration : https://help.codesys.com/webapp/_cds_vartypes_var_external;product=codesys;version=3.5.14.0