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 Jul 23, 2019 12:05 pm

All times are UTC+01:00




Post new topic  Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Mon Feb 11, 2019 5:26 pm 
Offline
Frequent User
Frequent User

Joined: Sun Apr 15, 2007 1:18 am
Posts: 162
Hello,
I have a little problem with property. (I use CODESYS V3.5 SP14)

I writted an objet FB1
FB1 Function block
VAR
ErrorFB1: Struct1;
END_VAR


I use MyFB1 :
VAR_GLOBAL
MyFB:FB1;
END_VAR


Struct1 is a structure, declared like this :
Struct1:
ErrorBit1:BOOL;
ErrorBit2:BOOL;
Error_Code:INT;
END_STRUCT


I can write 3 properties to get the value of each variable ErrorFB1.ErrorBit1, ErrorFB1.ErrorBit2, .... wtih properties like this :
Property Read1 : Bool;
GET
Read1:= ErrorFB1.ErrorBit1
;

It works well.

But I try to write only one property to get the entire structure ErrorFB1 :
Property ReadAll : ErrorFB1;

but It don't work.

I read somewhere, that I have to declare a REFERENCE, so I wrote :

Property ReadAll : REFERENCE TO ErrorFB1;
GET
ReadAll :=ErrorFB1;


In my programme I use :
Default1:=MyFB.ReadAll;

And I get an exception when I run the simulation mode.

I am a beginner in the use of OOP. I looked for examples but I founded only "simple" one.
I have certainly made a monstrous mistake somewhere, but I do not see it :oops:

Thank you in advance for any help. :D
BR


Top
   
PostPosted: Tue Feb 12, 2019 1:04 am 
Offline
Frequent User
Frequent User

Joined: Sun Apr 15, 2007 1:18 am
Posts: 162
Hello,

I found my error; :D

As the property is a REFERENCE, I have to write "REF=" instead of "=" in the GET acces :

Property ReadAll : REFERENCE TO ErrorFB1;
GET
ReadAll REF=ErrorFB1; :oops:

BR


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 2 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