<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to [SOLVED] Function with additional outputs</title><link href="https://forge.codesys.com/forge/talk/CODESYS-V2/thread/f9347dbe8f/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/CODESYS-V2/thread/f9347dbe8f/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/CODESYS-V2/thread/f9347dbe8f/</id><updated>2020-02-27T19:54:00.870000Z</updated><subtitle>Recent posts to [SOLVED] Function with additional outputs</subtitle><entry><title>[SOLVED] Function with additional outputs</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/f9347dbe8f/?limit=25#9b1b" rel="alternate"/><published>2020-02-27T19:54:00.870000Z</published><updated>2020-02-27T19:54:00.870000Z</updated><author><name>shooter</name><uri>https://forge.codesys.com/u/shooter/</uri></author><id>https://forge.codesys.comb9be2850127a6e357ec6f3330a41c743a531e852</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;The link refers to Version 3 Twincat, Here it works, however in 2.3 it is not working, you should have 1 output var returned by a function, however it is still possible to change other outputs within a function. &lt;br/&gt;
It all depends on the type of machine and software.&lt;br/&gt;
and yes you are correct, please use FB for this.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>[SOLVED] Function with additional outputs</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/f9347dbe8f/?limit=25#75f1" rel="alternate"/><published>2020-02-27T19:53:59.570000Z</published><updated>2020-02-27T19:53:59.570000Z</updated><author><name>Anonymous</name><uri>https://forge.codesys.com/u/*anonymous/</uri></author><id>https://forge.codesys.com762a3dd945ec7c799fa92458dc1bec23a209eecb</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;&lt;em&gt;Originally created by:&lt;/em&gt; scott_cunningham&lt;/p&gt;
&lt;p&gt;Looks like it's a limitation with the version you are running. In version 3, it works.  A crude workaround would be to create your function as a program instead and define any local variables as VAR_TEMP so they reset at every call.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>[SOLVED] Function with additional outputs</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/f9347dbe8f/?limit=25#1b1c" rel="alternate"/><published>2020-02-27T19:53:55.948000Z</published><updated>2020-02-27T19:53:55.948000Z</updated><author><name>ViggoTW</name><uri>https://forge.codesys.com/u/viggotw/</uri></author><id>https://forge.codesys.com105c4b58ea25eb28976e9470e5c57f2c6619f3c8</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Trying to add VAR_OUTPUT in a function results in compiler error 3820: " 'VAR_OUTPUT' and 'VAR_IN_OUT' not allowed in functions"&lt;/p&gt;
&lt;p&gt;The code I tried looked as follow&lt;/p&gt;
&lt;p&gt;Declaration:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="c"&gt;(* Declaration *)&lt;/span&gt;
&lt;span class="n"&gt;FUNCTION&lt;/span&gt; &lt;span class="n"&gt;F_fun&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;BOOL&lt;/span&gt;
&lt;span class="n"&gt;VAR_INPUT&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt;&lt;span class="n"&gt;bIn1&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;BOOL&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt;&lt;span class="n"&gt;bIn2&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;BOOL&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;END_VAR&lt;/span&gt;
&lt;span class="n"&gt;VAR_OUTPUT&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt;&lt;span class="n"&gt;bOut1&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;BOOL&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt;&lt;span class="n"&gt;bOut2&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;BOOL&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;END_VAR&lt;/span&gt;
&lt;span class="n"&gt;VAR&lt;/span&gt;
&lt;span class="n"&gt;END_VAR&lt;/span&gt;
&lt;span class="c"&gt;(* Code *)&lt;/span&gt;
&lt;span class="n"&gt;bOut1&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;bIn1&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;bOut2&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;NOT&lt;/span&gt; &lt;span class="n"&gt;bIn2&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;

&lt;/div&gt;</summary></entry><entry><title>[SOLVED] Function with additional outputs</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/f9347dbe8f/?limit=25#ecd8" rel="alternate"/><published>2020-02-27T19:53:54.645000Z</published><updated>2020-02-27T19:53:54.645000Z</updated><author><name>Anonymous</name><uri>https://forge.codesys.com/u/*anonymous/</uri></author><id>https://forge.codesys.com6e5f984099836ef5137489a6c874a69fd9a256f4</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;&lt;em&gt;Originally created by:&lt;/em&gt; scott_cunningham&lt;/p&gt;
&lt;p&gt;Define the outputs the same way as a function block. You can keep the traditional single output and and the second and third and fourth outputs as var outputs or you can delete the traditional output type and put all outputs as var outs.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>[SOLVED] Function with additional outputs</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/f9347dbe8f/?limit=25#22f5" rel="alternate"/><published>2020-02-27T19:53:51.010000Z</published><updated>2020-02-27T19:53:51.010000Z</updated><author><name>ViggoTW</name><uri>https://forge.codesys.com/u/viggotw/</uri></author><id>https://forge.codesys.com4efaaf0f0cac5c49432daf92e47f954a5b3e8e9c</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi,&lt;br/&gt;
I am used to functions returning only one data type, depending on how the function itself is declared (for example FUNCTION fName : INT, which returns an INT).&lt;br/&gt;
However, I read the follwoing at Beckhoff's webpage in their chapter about functions&lt;/p&gt;
&lt;p&gt;&lt;span&gt;[1]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;I am familiar with this in Function Blocks where you declare your output variables for example inside a VAR_OUTPUT (...) END_VAR, but I am hoping that someone could show me an example of additional outputs in a Function?&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>