![]() ![]() ![]() ![]() ![]() ![]() |
||
![]() |
||
![]() ![]() ![]() ![]() This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc. |
||
![]() |
|
![]() |
|
Thread Tools | Display Modes |
![]() |
#1 |
Member
![]() ![]() Join Date: Apr 2021
Location: Bulawayo
Posts: 3
|
![]()
Hi,
I'm getting a bunch of these warnings when I build the program in Connected Components Workbench. The program is legacy code. The program runs fine but I cannot clear these warnings without changing the program structure. Should I be worried ![]() ![]() |
![]() |
![]() |
#2 |
Member
![]() ![]() Join Date: Nov 2016
Location: NL
Posts: 350
|
Yes. Check if the function blocks maintain state between consecutive calls. If they don't, then you might be fine. But there still is something wrong in the design of your code.
One fundamental difference between function and function block is that the latter maintains state between consecutive calls. If your function block does not require this, then you could (and should) have used a function instead. Variables declared inside a function do not maintain state between consecutive calls of the function. If the function blocks inside the function require state to be maintained between two calls then your code may not behave as you would expect. I apologize if the above is confusing. It is somewhat difficult to describe this in a meaningful way if you don't have a good understanding of the underlying conceptual differences between functions and function blocks. Even more so since English is not my mother tongue, I am not a native speaker. |
![]() |
![]() |
#3 |
Lifetime Supporting Member
|
+1 your English is very good. I tutor ESL and it is fine. Somewhat OT I guess, but anyway you have no reason to apologize. Have a great week!!
__________________
"Instant success teaches one nothing. Failure teaches one everything one needs to succeed." ![]() |
![]() |
![]() |
#4 |
Member
![]() ![]() Join Date: Apr 2021
Location: Bulawayo
Posts: 3
|
Thank you very much Toine for the explanation.
I have understood your point, that User Defined Function blocks are best used in situations where you would like to maintain/save the state. This raises another question for me, what is the best place to call a function block within a program, should I call them within the main program block and avoid calling them within functions?. How best should I structure my program when dealing with function blocks, thank you... Your English is excellent, we are both not native speakers so don't worry.... |
![]() |
![]() |
#5 |
Member
![]() ![]() Join Date: Nov 2016
Location: NL
Posts: 350
|
The only meaningful thing I can say about that in this context is that function blocks should not be called from inside a function, since a function cannot be relied upon to maintain state between calls. Now which way to go from here depends entirely on what is going on in your function and the function blocks inside.
If you do have function blocks inside a function, there are two ways you can go to resolve the potential issues. Which way to go cannot be determined without looking into the details of the function and the function block(s) inside it. Either the function block actually does not store state between calls. In that case it is not required to be a function block and should be rewritten to be a function instead. Or the function block does require to maintain state between two calls. Then the function in which it is called should not have been a function so it should be rewritten into a function block. Thanks saultgeorge and anglebert on the language. It is nice to know one is understandable ![]() |
![]() |
![]() |
#6 |
Member
![]() ![]() Join Date: Apr 2021
Location: Bulawayo
Posts: 3
|
Okay, it's getting clearer now thank you...
|
![]() |
![]() |
Bookmarks |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
MPI comunication | Manuel Raposo | LIVE PLC Questions And Answers | 22 | July 16th, 2007 07:24 AM |
siemens step 5 function blocks | stevelawson | LIVE PLC Questions And Answers | 38 | February 20th, 2007 02:26 AM |
Function Blocks | blackslipper | LIVE PLC Questions And Answers | 0 | January 4th, 2006 08:42 AM |
learning function and data blocks (Step7) | Pandiani | LIVE PLC Questions And Answers | 7 | April 27th, 2005 10:56 AM |
Siemens step 5 function blocks | stevelawson | LIVE PLC Questions And Answers | 1 | February 13th, 2004 08:43 AM |