InOut Parameter issue

2023-06-27
2023-07-04
  • cullenary767

    cullenary767 - 2023-06-27

    Good Day

    Im having an issue that im hoping someone could help me with.
    I have created a function that uses an in_out variable. The function also contains actions.

    I then created an object from the function and assigned the in_Out variable before using the objects actions. However, when i try to call the objects actions it returns a "VAR_IN_OUT must be assigned when calling function". This is odd because is have already assigned the in_out parameter to the object before I used the object action.

    Im using codesys v3.5 sp19

    any help would be very appreciated

     
  • ben1 - 2023-07-01

    Hey pal,

    Any reason you choose an action & not a method?
    I have not used actions myself, but if it handle like an FB I believe it wants the IN_OUT to be nested in the calls brackets. ( EG. fbHomeSystems.ACTInit(stKineDataRef:=stKineDataRef); )

    You could try doubling up (being an in_out, I think it won't matter), or you could try only referencing it in the direct action rather than the call above, unless of course it is needed elsewhere in the FB.

    Let us know how that pans out.

    Cheers,
    Ben

     
    • cullenary767

      cullenary767 - 2023-07-03

      Thank you Ben for your reply!
      I initially wanted to use actions because i dont been to pass information in and out of the block. I believe this would have been "neater" but then i encountered this issue.

      I did try the assignment as you suggested "fbHomeSystems.ACTInit(stKineDataRef:=stKineDataRef)" however this did not work either. I have reverted back to using methods and it does seem to work fine barring afew warnings about externaly accessing an internal In_out parameter from an external method call.

      I just thought this was quite odd that codesys would have an issue like this in regards to actions but not methods.Wouldnt the assignment such as fbHomeSystems(stKineDataRef:=stKineDataRef);
      be carried out throughout the objects life during execution ?

       
  • ben1 - 2023-07-04

    No problem.

    I had a quick look at one of my programs and there are some actions inherent to some code I have brought in for email etc.

    It appears to me they are all called from within the FB or POU that they are used in, not outside as you have displayed in your snip.

    I see you have called it directly after the FB, so can you not call it directly at the bottom from within the FB instead?

    I believe usually you could call the action from somewhere else, but as you mentioned yourself it does not pass any information, so perhaps the in_out var is causing it some confusion.

    A good test might be to try removing the in out parameter.

     

Log in to post a comment.