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 Mon Feb 24, 2020 9:39 pm

All times are UTC+01:00




Post new topic  Reply to topic  [ 1 post ] 
Author Message
PostPosted: Tue Jan 07, 2020 8:17 pm 
Offline

Joined: Tue Jan 07, 2020 6:47 pm
Posts: 2
This is a bug report of sorts, as well as a way for me to leave a note for others who may encounter this issue.

Calling a method in a CFC is pretty straightforward when that method belongs to another function block, but it doesn't work very well when the method belongs to the CFC itself

If the internal method has input variables, the compiler will give a C0040 error "Function 'MethodName' requires exactly '#' inputs", even when the input pins are all visible and connected.

I've found 2 workarounds,
  1. Don't use inputs, just call local variables directly from the method. This gets clunky really fast so isn't a great solution if you need inputs. Also, the method's box will just be floating in the CFC with no visible connections, which kinda defeats the purpose of CFC
  2. Give the method a return type or an output. For whatever reason, this avoids the compile error. You never have to write to the output or use it in the CFC, but if you hide the output pin the error will return so you have to just leave it dangling or connect it to something

Image

Hopefully these workarounds won't always be necessary in the future


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

All times are UTC+01:00


Who is online

Users browsing this forum: Andreas Kehrer and 9 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