Hi Douyi
This bit about FCs and FBs comes straight out of the IEC6-1131-3 standard. This is well-known and much discussed here and pretty much dismissed by the majority.
In pure IEC-speak, an FC should have only one Return Value, usually signified by Siemens as RET_VAL. Whatever you build it to do, the answer should be expressable as a single RET_VAL. The FC should be regarded as a RET_VAL generator whose answer is only dependent on the input parameters, not stored data. The result of the FC should be completely independent of whether this is the first or hundred-and-first time it has executed.
By contrast, an FB can have multiple output parameters and has its own associated instance data block for holding static variables. An FC has no concept of static variables as jmrcalin has indicated. If you have coded something like a moving average, the result of this does very much depend on how many times it has executed. The data carried forward between successive executions should justify this as being appropriate for an FB with its IDB.
That's 'pure' IEC-speak.
Of course, you can build an FC with twenty output parameters and store loads of data in fifty different data blocks. You can write all your code as FCs, or FBs, or a mixture in-between. So the question is really why didn't Siemens (or anyone else, for that matter) stick absolutely rigidly to the IEC-spec? Commercial suicide, I suspect. I don't know any manufacturer who has signed up for this and forbidden or prevented users to do what they want. We, the customers, demand the right to be wrong sometimes. Of course evry manufacturer has taken different bits of the IEC spec and enforced them more rigidly than others. How they decided which bits were important and which bits weren't we'll probably never know.
Regards
Ken