<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to invalid value from function call</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/fed1d383fb/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Engineering/thread/fed1d383fb/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Engineering/thread/fed1d383fb/</id><updated>2020-02-27T13:48:40.162000Z</updated><subtitle>Recent posts to invalid value from function call</subtitle><entry><title>invalid value from function call</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/fed1d383fb/?limit=25#8d1e" rel="alternate"/><published>2020-02-27T13:48:40.162000Z</published><updated>2020-02-27T13:48:40.162000Z</updated><author><name>travlytle</name><uri>https://forge.codesys.com/u/travlytle/</uri></author><id>https://forge.codesys.com960af1fdd722b8eef7eacc7eb632da08ba9d59a7</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;This worked thanks!&lt;/p&gt;
&lt;p&gt;I changed the function by removing the out var, and setting the function name := (equation).&lt;/p&gt;
&lt;p&gt;And then updated the code to:&lt;/p&gt;
&lt;p&gt;// function call - linear interpolation&lt;br/&gt;
interp_out0 := lin_interp( x0:= 0, x1:= 100, y0:= 0, y1:= 50, in:= interp_in);&lt;/p&gt;
&lt;p&gt;// function call - linear interpolation (same as above, different format)&lt;br/&gt;
interp_out1 := lin_interp( 0, 100, 0, 100, interp_in ); &lt;/p&gt;
&lt;p&gt;I believe I found the old method in the help file too, not so helpful!&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>invalid value from function call</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/fed1d383fb/?limit=25#92d1" rel="alternate"/><published>2020-02-27T13:48:40.034000Z</published><updated>2020-02-27T13:48:40.034000Z</updated><author><name>Anonymous</name><uri>https://forge.codesys.com/u/*anonymous/</uri></author><id>https://forge.codesys.coma73b26f2a7ef4250621833c5e3d2af61e8a283c0</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;If you only have one output for the function, don't define it as a var out. &lt;/p&gt;
&lt;p&gt;Don't:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="k"&gt;FUNCTION&lt;/span&gt; &lt;span class="n"&gt;MyFunction&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;VarIn&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;BOOL&lt;/span&gt;&lt;span class="p"&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;Var2&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;INT&lt;/span&gt;&lt;span class="p"&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;Out1&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;BOOL&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;END_VAR&lt;/span&gt;
&lt;span class="n"&gt;Out1&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;VarIn&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;Do:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="k"&gt;FUNCTION&lt;/span&gt; &lt;span class="n"&gt;MyFunction&lt;/span&gt; &lt;span class="p"&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;VarIn&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;BOOL&lt;/span&gt;&lt;span class="p"&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;Var2&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;INT&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;END_VAR&lt;/span&gt;
&lt;span class="n"&gt;MyFunction&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;VarIn&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;Now you can call it in the way you want:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;Answer&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;MyFunction&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;TRUE&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;27&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;If you define one or more VAR_OUTPUTs, then you have to use the full notation so the compiler knows which output you want.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>invalid value from function call</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/fed1d383fb/?limit=25#ce1f" rel="alternate"/><published>2020-02-27T13:48:39.966000Z</published><updated>2020-02-27T13:48:39.966000Z</updated><author><name>travlytle</name><uri>https://forge.codesys.com/u/travlytle/</uri></author><id>https://forge.codesys.com0efbd9f8577887390556b97cdc0210e1e3b6c56b</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;This doesn't work:  interp_out1 := lin_interp.out;&lt;/p&gt;
&lt;p&gt;It doesn't like the .out&lt;/p&gt;
&lt;p&gt;It says 'out' is no input of 'lin_interp'&lt;/p&gt;
&lt;p&gt;The function in the tree menu shows, lin_interp (FUN).  This would be a function or not necessarily?&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>invalid value from function call</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/fed1d383fb/?limit=25#dab2" rel="alternate"/><published>2020-02-27T13:48:39.890000Z</published><updated>2020-02-27T13:48:39.890000Z</updated><author><name>yannickasselin1</name><uri>https://forge.codesys.com/u/yannickasselin1/</uri></author><id>https://forge.codesys.comb71f4c4234560c6b65396c1e102f030830692be6</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Are you sure it is a function?&lt;/p&gt;
&lt;p&gt;It seems to be a function block, which is different.&lt;/p&gt;
&lt;p&gt;Try this:&lt;/p&gt;
&lt;p&gt;lin_interp( 0, 100, 0, 100, interp_in );&lt;br/&gt;
interp_out1 := lin_interp.out;&lt;/p&gt;
&lt;p&gt;This should work if it is a function block.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>invalid value from function call</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/fed1d383fb/?limit=25#ede3" rel="alternate"/><published>2020-02-27T13:48:39.817000Z</published><updated>2020-02-27T13:48:39.817000Z</updated><author><name>travlytle</name><uri>https://forge.codesys.com/u/travlytle/</uri></author><id>https://forge.codesys.com936e3fb63253edb260a27e4cf8f6afa231b011be</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;I've created a function for linear interpolation and depending on how I call it either works or doesn't.  Using the shorter method of function call doesn't work.  I'm using Codesys 3.5 SP8 Patch 4.&lt;/p&gt;
&lt;p&gt;interp_in := 7;&lt;/p&gt;
&lt;p&gt;// function call - linear interpolation&lt;br/&gt;
lin_interp( x0:= 0, x1:= 100, y0:= 0, y1:= 50, in:= interp_in, out=&amp;gt; interp_out0 );&lt;/p&gt;
&lt;p&gt;// function call - linear interpolation (same as above, different format)&lt;br/&gt;
interp_out1 := lin_interp( 0, 100, 0, 100, interp_in );     //this format is not working correctly, I don't know why&lt;/p&gt;
&lt;p&gt;&lt;img alt="IMG: 2016" rel="nofollow" src="https://forum.codesys.com//download/file.php?id=1879"/&gt;&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>