CODESYS - the IEC 61131-3 automation software

Welcome to the official CODESYS Forum by 3S-Smart Software Solutions GmbH | A member of the CODESYS Group
Deutsche Version English version russian version 
It is currently Tue Nov 12, 2019 4:25 am

All times are UTC+01:00




Post new topic  Reply to topic  [ 8 posts ] 
Author Message
PostPosted: Tue Jun 04, 2019 12:22 pm 
Offline

Joined: Thu Oct 04, 2018 10:20 am
Posts: 10
Using dot operator of a struct property is not supported, which makes the property painful to use.

I see no reason why this is not supported.

The dot operator can be used directly on the return value of a method by typing the method name twice (which is suggested by the auto complete).

Another maybe unrelated point: why the private local data of a function block can be read from outside?
Shouldn't the compiler prevent it?

Following is an example to make my point clear:

Attachment:
stfoo.PNG


Attachment:
GetFoo.PNG


Attachment:
prgfoo.PNG


You do not have the required permissions to view the files attached to this post.


Last edited by kai_sew on Tue Jun 11, 2019 8:53 am, edited 2 times in total.

Top
   
PostPosted: Tue Jun 04, 2019 3:59 pm 
Offline

Joined: Thu Aug 04, 2016 4:21 pm
Posts: 41
if you are missing the SmartCoding functionality for dots, check settings at Tools-->Options-->SmartCoding..


You do not have the required permissions to view the files attached to this post.


Top
   
PostPosted: Thu Jun 06, 2019 7:03 am 
Offline

Joined: Thu Sep 13, 2018 3:08 pm
Posts: 24
He is clearly missing the feature of directly using a struct member of a struct property.

Code:

IF _fb.structProperty.xStructMember = TRUE THEN
    // do something
END_IF



However, using a member of a struct of a method return value does NOT work for me as well.

Code:
IF _fb.structMethod().xStructMember THEN
    // do something
END_IF


Top
   
PostPosted: Mon Jun 10, 2019 4:43 pm 
Offline

Joined: Thu Jul 09, 2015 9:55 pm
Posts: 35
Code:
IF fb.Prop.xBool THEN
   // something
END_IF


Indeed dosent work;
Quote:
C0185: It is not possible to perform component access '.', index access '[]' or call '()' on result of function call. Assign result to help variable first.


Top
   
PostPosted: Tue Jun 11, 2019 7:44 am 
Offline

Joined: Thu Oct 04, 2018 10:20 am
Posts: 10
You are correct.

Return value of a method normally also does not work.

However, by typing the method name twice, which is suggested by the code auto complete, it shows no error any more.

I just attached an example.

jago85 wrote:
He is clearly missing the feature of directly using a struct member of a struct property.

Code:

IF _fb.structProperty.xStructMember = TRUE THEN
    // do something
END_IF



However, using a member of a struct of a method return value does NOT work for me as well.

Code:
IF _fb.structMethod().xStructMember THEN
    // do something
END_IF


Top
   
PostPosted: Tue Jun 11, 2019 7:45 am 
Offline

Joined: Thu Oct 04, 2018 10:20 am
Posts: 10
Thank you for your reply.

But that is not my point.

D. Kugler wrote:
if you are missing the SmartCoding functionality for dots, check settings at Tools-->Options-->SmartCoding..


Top
   
PostPosted: Sat Jun 15, 2019 7:54 pm 
Offline

Joined: Thu Jul 09, 2015 9:55 pm
Posts: 35
This works. Beware that the property is writeable doing this (Set-property not needed)


You do not have the required permissions to view the files attached to this post.


Top
   
PostPosted: Mon Jun 17, 2019 12:38 pm 
Offline

Joined: Thu Oct 04, 2018 10:20 am
Posts: 10
Thanks for the workaround.

Hope 3S will provide an official support.

somlioy wrote:
This works. Beware that the property is writeable doing this (Set-property not needed)


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

All times are UTC+01:00


Who is online

Users browsing this forum: No registered users 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