SimonGoldsworthy said:
...and it may as well be an FC.
I agree with that sentiment.
You should open the instance DB before calling the FB, otherwise you can never call the FB more than once. Very important note: You must also set AR2 prior to calling the FB as all variable access within a FB actually uses [AR2,P#x.y] indirect addressing.
I have to look at what my German friends are doing then as this code appears in a FB called via UC.
Funny thing its on the second segment, after some STAT's were used in the first. The structure again mirror'd the calling FB though.
If calling an FB from an FB with UC, declare the FB you are calling as a multiple instance in the STAT area to make sure the instance data for the FB is allocated,
I wholeheartedly agree with that too.
In the systems I'm working at the moment, we have one German supplier who's been playing every trick there is (I've learned a few things), which includes doing this very thing and also passing in FB's as 'IN' ANY parameters, FB's calling themselves (ie FB32 calls FB32) and I/O addresses stored in pointer format in datawords.
Forc the UC's the FB's STAT's are all made up of UDT's and all have the same two IN parameters, then the first block has all the UDT's, then blocks called within have the UDT's in order up to the point where the blocks specific UDT is.
I feel they did a lot of things just to make it awkward for other engineers to follow, keeping the knowledge in-house, they say its because of scan time restraints.
Maybe in reality a bit of both.