Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched. Close

Mechanical Engineer Seeking CODESYS Programming Help For Giant Mech - Pointers & Functions

cperrin
2021-07-14
2021-07-15
  • cperrin

    cperrin - 2021-07-14

    Here is what I'm working on for those that might be interested. https://www.youtube.com/channel/UCepKsWePdtKjsud7cqjbB9A

    I'm hoping this is the right place to just post general questions as I'm trying to figure out how to program more complex things in Codesys.

    First thing is I'm trying to figure out how to work with Functions using Pointers. I think I've got it mostly figured out but the part that doesn't make sense is how the function needs to return something. Is it possible to not return anything from a function call? Otherwise I'm going to make some sort of dummy variable.

     
    • Ingo

      Ingo - 2021-07-14

      Hey, that's an amazing project. I'd be very proud, if parts of our software
      would make this beast move. Are you already using CODESYS in it, or is it a
      new modification, on which you are working?

      Regarding your question:
      You always need to return s.th. in IEC. So usually you return a BOOL, if
      you have nothing else to say. There is no such thing, like a void function.

      It doesn't also feel natural in IEC, as the function represents more or
      less its return value. When you return a resilt, you assign it to the name
      of the function.

       
  • i-campbell

    i-campbell - 2021-07-15

    You can delete the return type after insertion in the function's declaration section, no dramas.

     
  • cperrin

    cperrin - 2021-07-15

    Thanks. So it would seem it is not possible but Codesys seems happy enough with it to just be called without assigning to a variable as long as you're not assigning anything to the output in the function. Still need to define the type of output but no need to do anything more than that.

     

Log in to post a comment.