<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to Function Block with Variable Number of Inputs</title><link href="https://forge.codesys.com/forge/talk/CODESYS-V2/thread/77a44e0d35/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/CODESYS-V2/thread/77a44e0d35/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/CODESYS-V2/thread/77a44e0d35/</id><updated>2020-02-27T19:45:15.044000Z</updated><subtitle>Recent posts to Function Block with Variable Number of Inputs</subtitle><entry><title>Function Block with Variable Number of Inputs</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/77a44e0d35/?limit=25#95ff" rel="alternate"/><published>2020-02-27T19:45:15.044000Z</published><updated>2020-02-27T19:45:15.044000Z</updated><author><name>robkristiaan</name><uri>https://forge.codesys.com/u/robkristiaan/</uri></author><id>https://forge.codesys.comd15b00acd81b2ac2b343c9af6b514a81117bb84d</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;You can create a functionblock with "variable" amount of input by using an array and an index number&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="nv"&gt;FUNCTION_BLOCK&lt;/span&gt; &lt;span class="nv"&gt;VarInput&lt;/span&gt;
&lt;span class="nv"&gt;VAR_INPUT&lt;/span&gt;
   &lt;span class="nv"&gt;awInput&lt;/span&gt;:&lt;span class="nv"&gt;ARRAY&lt;/span&gt;[&lt;span class="mi"&gt;0&lt;/span&gt;..&lt;span class="mi"&gt;255&lt;/span&gt;] &lt;span class="nv"&gt;OF&lt;/span&gt; &lt;span class="nv"&gt;WORD&lt;/span&gt;&lt;span class="c1"&gt;; (*255 free asignable inputs*)&lt;/span&gt;
   &lt;span class="nv"&gt;byAmount&lt;/span&gt;:&lt;span class="nv"&gt;BYTE&lt;/span&gt;&lt;span class="c1"&gt;; (*for use in a for loop to know when to stop, for example*)&lt;/span&gt;
&lt;span class="nv"&gt;END_VAR&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;

&lt;/div&gt;</summary></entry><entry><title>Function Block with Variable Number of Inputs</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/77a44e0d35/?limit=25#11a5" rel="alternate"/><published>2020-02-27T19:45:13.767000Z</published><updated>2020-02-27T19:45:13.767000Z</updated><author><name>shooter</name><uri>https://forge.codesys.com/u/shooter/</uri></author><id>https://forge.codesys.com3382ef3683229dea9a84f72579c3dc1e89a18aa1</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;No impossible as the compiler looks at how many inputs are used.&lt;/p&gt;
&lt;p&gt;There is a work around it.&lt;/p&gt;
&lt;p&gt;when using AND for example&lt;/p&gt;
&lt;p&gt;You can make your own functionblock with many inputs and the unused ones fill with true.&lt;/p&gt;
&lt;p&gt;result:=inp1 and inp2 and inp3  etc.&lt;/p&gt;
&lt;p&gt;you must declare all inputs&lt;/p&gt;
&lt;p&gt;inp2:bool:=true; will not work.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Function Block with Variable Number of Inputs</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/77a44e0d35/?limit=25#8d42" rel="alternate"/><published>2020-02-27T19:45:10.212000Z</published><updated>2020-02-27T19:45:10.212000Z</updated><author><name>bvanbata</name><uri>https://forge.codesys.com/u/bvanbata/</uri></author><id>https://forge.codesys.com61e0c704b133ca9b15b68b03dd0c3d9de8630e3d</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Can anyone tell me how I can create a function block that has a variable number of inputs?  For example, in the online documentation for V2.3 it says:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;'Insert' 'Input of box' in CFC &lt;/p&gt;
&lt;p&gt;Shortcut: &amp;lt;ctrl&amp;gt; + &lt;u&gt;&lt;/u&gt;&amp;lt;/ctrl&amp;gt;&lt;/p&gt;&lt;u&gt;
&lt;p&gt;This command is used to insert an input at a box. The number of inputs &amp;gt; is variable for many operators (e.g. ADD can have two or more inputs). &lt;/p&gt;
&lt;p&gt;To increase the number of inputs for such an operator by one, the box &amp;gt; itself must be selected &lt;/p&gt;
&lt;/u&gt;&lt;/blockquote&gt;&lt;u&gt;
&lt;/u&gt;&lt;p&gt;&lt;u&gt;Is it possible for me to create a function in my own library that has the same type of functionality, where the user can select the number of inputs?&lt;/u&gt;&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>