Author |
Message |
yannickasselin1
|
PostPosted: Mon Dec 02, 2019 11:21 pm |
|
Offline |
Frequent User |
 |
Joined: Mon Apr 28, 2014 7:05 pm Posts: 104
|
Hi,
Is it possible to use __VARINFO inside a Function block to get info on the instance of the function block like this:
stVarInfo := __VARINFO(THIS^);
If I do this in TwinCat, VisualStudio crashes. I would like to get the name of the instance of the function block from inside the function block.
Thank you.
|
|
Top |
|
 |
singleton
|
PostPosted: Tue Dec 03, 2019 7:53 am |
|
Joined: Thu Aug 04, 2011 11:16 am Posts: 87
|
|
Top |
|
 |
yannickasselin1
|
PostPosted: Tue Dec 03, 2019 3:59 pm |
|
Offline |
Frequent User |
 |
Joined: Mon Apr 28, 2014 7:05 pm Posts: 104
|
Thank you,
It works but I also get the name of the TC project and the name of the PLC project in front of the variable name. I should be able to figure a way to get rid of what I don't need using some string functions.
'Tc3_TestRecipe.PLC_TestRecipe.Main.fbTest[0]'
I only need 'Main.fbTest[0]'
Thank you.
|
|
Top |
|
 |
scott_cunningham
|
PostPosted: Wed Dec 04, 2019 4:16 am |
|
Offline |
Frequent User |
 |
Joined: Fri Sep 02, 2011 8:02 pm Posts: 309
|
Those items you don’t want are part of the instance path, that is why they are included. Simply make a function that starts at the string end, and goes backwards until it finds the second period. Then return the MID of the string, starting at that point.
_________________ Scott Cunningham KEB America, Inc. www.kebblog.comwww.kebamerica.com
|
|
Top |
|
 |