By the way, would be nice from 3S to release documentation on type independent numeric variables ANY_NUM....
I know, this must work internally.... And sometimes it's useful when developing more or less generic FBs, libraries....
Also, I've noticed, that some functions (MIN, MAX) can receive more than 2 parameters in ST?
How to declare such user functions?
P.
These are really CoDeSys internals... but this features are making things elegant and excellent....
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
jzhvymetal hat geschrieben:
Is there any way to get the name and type of current variable in runtime.
for example
myDINT: DINT;
myCurrentVariableName: STRING;
myCurrentVariableName := toString(myDINT); ( myCurrentVariableName would equal "myDINT" )
if TYPE(myDINT) = DINT then
( True if variable is DINT )
endif
Try to search for "{attribute reflection}" and "{attribute instance-path}".
This works for FB instances... I quote online help....
singleton hat geschrieben:
Hi Strucc,
he was asking for variable instances not for FB instances. That's why I did not offer this instance-path stuff
But anyway, you're right:
An official support of ANY_NUM would be great
And if I could add this to my whishlist:
OVERLOADING of methods!!!!
I want to raise my hand also for overloading. Also I wish CoDeSys would give more document how to use the following types:
ANY
ANY_DERIVED
ANY_ELEMENTARY
ANY_MAGNITUDE
ANY_BIT
ANY_STRING
ANY_DATE
ANY_NUM
ANY_REAL
ANY_INT
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Is there any way to get the name and type of current variable in runtime.
for example
myDINT: DINT;
myCurrentVariableName: STRING;
myCurrentVariableName := toString(myDINT); ( myCurrentVariableName would equal "myDINT" )
if TYPE(myDINT) = DINT then
( True if variable is DINT )
endif
Hi,
to get the type of a variable you can use conditional pragmas:
To get the name of a variable you can try the attribute ```
'parameterstringof'
``` But as far as I know this is only working inside visualizations.
By the way, would be nice from 3S to release documentation on type independent numeric variables ANY_NUM....
I know, this must work internally.... And sometimes it's useful when developing more or less generic FBs, libraries....
Also, I've noticed, that some functions (MIN, MAX) can receive more than 2 parameters in ST?
How to declare such user functions?
P.
These are really CoDeSys internals... but this features are making things elegant and excellent....
Try to search for "{attribute reflection}" and "{attribute instance-path}".
This works for FB instances... I quote online help....
In the main program PLC_PRG an instance myPOU of function block POU is called:
And... you can always check an FB instance for interface compatibility....
(instead of types)
Hi Strucc,
he was asking for variable instances not for FB instances. That's why I did not offer this instance-path stuff
But anyway, you're right:
An official support of ANY_NUM would be great
And if I could add this to my whishlist:
OVERLOADING of methods!!!!
I want to raise my hand also for overloading. Also I wish CoDeSys would give more document how to use the following types:
ANY
ANY_DERIVED
ANY_ELEMENTARY
ANY_MAGNITUDE
ANY_BIT
ANY_STRING
ANY_DATE
ANY_NUM
ANY_REAL
ANY_INT