CODESYS - the IEC 61131-3 automation software

Welcome to the official CODESYS Forum
Deutsche Version English version russian version 
It is currently Thu Sep 20, 2018 9:56 pm

All times are UTC+01:00




Post new topic  Reply to topic  [ 9 posts ] 
Author Message
 Post subject: Get Type Of a Variable
PostPosted: Thu Mar 17, 2016 1:52 pm 
Offline

Joined: Mon Apr 28, 2014 7:05 pm
Posts: 87
Hi all,

Is it possible to get the type of a variable during runtime?

Something like : typeof in C# ?

Thank you.


Top
   
PostPosted: Thu Mar 17, 2016 3:43 pm 
Offline
Site Admin

Joined: Mon Jun 26, 2006 10:51 am
Posts: 79
Code:
//Declaration
VAR
   MyVarInfo: __SYSTEM.VAR_INFO;
   MyTestVar: INT;
END_VAR

//Code
MyVarInfo:= __VARINFO(MyTestVar);
//after this line of code MyVarInfo contains all information obout this variable - just watch in online mode and you will understand


BR
Ralph


Top
   
PostPosted: Fri Mar 18, 2016 3:23 pm 
Offline

Joined: Mon Apr 28, 2014 7:05 pm
Posts: 87
Thanks, it works fine!

But how can someone get some info about these special functions?

I cannot find anything about it in the help.

Thank you.


Top
   
PostPosted: Fri Mar 18, 2016 9:21 pm 
Offline
Frequent User
Frequent User
User avatar

Joined: Tue Jun 06, 2006 9:03 am
Posts: 406
Hi Ralph,

Thanks for the tip. This is very useful!

Tim


Top
   
PostPosted: Sat Mar 19, 2016 8:29 am 
Offline

Joined: Thu Aug 04, 2011 11:16 am
Posts: 83
yannickasselin1 wrote:
Thanks, it works fine!

But how can someone get some info about these special functions?

I cannot find anything about it in the help.

Thank you.


Type "System." e.g. inside a ST Editor to come to those fancy stuff ;-)


Top
   
PostPosted: Thu Feb 23, 2017 4:16 am 
Offline
User avatar

Joined: Tue Aug 30, 2011 1:21 am
Posts: 92
Ralph Holz wrote:
Code:
//Declaration
VAR
   MyVarInfo: __SYSTEM.VAR_INFO;
   MyTestVar: INT;
END_VAR

//Code
MyVarInfo:= __VARINFO(MyTestVar);
//after this line of code MyVarInfo contains all information obout this variable - just watch in online mode and you will understand


BR
Ralph


Is there anyway to get a structures variables members without knowing them? Meaning if you pass a structure to _VARINFO how can you get info about it members?

_________________
The Original SoMachine Ninja


Last edited by jzhvymetal on Thu Feb 23, 2017 3:47 pm, edited 1 time in total.

Top
   
PostPosted: Thu Feb 23, 2017 9:17 am 
Offline
Frequent User
Frequent User

Joined: Wed May 04, 2016 6:00 pm
Posts: 238
If internals variables are exported to symbolic comunication, I am thinking that you want is posible via cmpiecvaracces.

But i have not found information about that library.

I have could see information, using cmpiecvaraccesd, of program variables but not about fb members


Top
   
PostPosted: Wed Feb 21, 2018 8:36 am 
Offline

Joined: Sun Feb 12, 2017 11:29 am
Posts: 4
Josep M. Rams wrote:
If internals variables are exported to symbolic comunication, I am thinking that you want is posible via cmpiecvaracces.

But i have not found information about that library.

I have could see information, using cmpiecvaraccesd, of program variables but not about fb members


Hi, would you please post how to use iecvaraccess.

Thanks


Top
   
PostPosted: Wed Feb 21, 2018 8:37 am 
Offline

Joined: Sun Feb 12, 2017 11:29 am
Posts: 4
jzhvymetal wrote:
Ralph Holz wrote:
Code:
//Declaration
VAR
   MyVarInfo: __SYSTEM.VAR_INFO;
   MyTestVar: INT;
END_VAR

//Code
MyVarInfo:= __VARINFO(MyTestVar);
//after this line of code MyVarInfo contains all information obout this variable - just watch in online mode and you will understand


BR
Ralph


Is there anyway to get a structures variables members without knowing them? Meaning if you pass a structure to _VARINFO how can you get info about it members?


Hi,
This is exactly what i need, did you find any workaround?

Thank you


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 9 posts ] 

All times are UTC+01:00


Who is online

Users browsing this forum: Andreas Kehrer and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited