title: Is it possible to define a CAPL function returning a text string?
body: <p>I develop CAPL scripts in Vector CANoe, and I need to define several functions returning text strings. In C, I would write something like this:</p>
  
  <pre><code>char * ErrorCodeToMsg(int code)
  </code></pre>
  
  <p>or</p>
  
  <pre><code>char [] ErrorCodeToMsg(int code)
  </code></pre>
  
  <p>In CAPL, both definitions fail with a <code>parse error</code>. The only working solution I came up with so far is:</p>
  
  <pre><code>variables {
    char retval[256];
  }
  
  void ErrorCodeToMsg(int code) {
    char [] msg = "Hello word";
    strncpy(retval, msg, 256);
  }
  </code></pre>
  
  <p>Of course this is very ugly, because each call to <code>ErrorCodeToMsg</code> requires two statements instead of one. Is there a better way?</p>