<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to Flexible variable type for functions: ANY_TO_xxx</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/8b09369d84/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Engineering/thread/8b09369d84/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Engineering/thread/8b09369d84/</id><updated>2020-02-27T14:14:27.364000Z</updated><subtitle>Recent posts to Flexible variable type for functions: ANY_TO_xxx</subtitle><entry><title>Flexible variable type for functions: ANY_TO_xxx</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/8b09369d84/?limit=25#f98e" rel="alternate"/><published>2020-02-27T14:14:27.364000Z</published><updated>2020-02-27T14:14:27.364000Z</updated><author><name>Anonymous</name><uri>https://forge.codesys.com/u/*anonymous/</uri></author><id>https://forge.codesys.com3e01e60440355c85141de7757552240eadcbfdc2</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;&lt;em&gt;Originally created by:&lt;/em&gt; fk5&lt;/p&gt;
&lt;p&gt;Yeah... This is what I suspected.&lt;br/&gt;
I currently have functions like intScale(), realScale() and intRamp(), realRamp(), etc.&lt;br/&gt;
And I have functions that are done in REAL, then I have to use &lt;span style="color: #0040FF;"&gt;XXX_TO_XXX&lt;/span&gt; everywhere. &lt;br/&gt;
Its annoying. I was hoping for a magical variable type that I didn't know about.  &lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Flexible variable type for functions: ANY_TO_xxx</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/8b09369d84/?limit=25#a7c3" rel="alternate"/><published>2020-02-27T14:14:27.009000Z</published><updated>2020-02-27T14:14:27.009000Z</updated><author><name>i-campbell</name><uri>https://forge.codesys.com/u/i-campbell/</uri></author><id>https://forge.codesys.comde3e916a06730839fe1ade32e4e1edd6225c84e8</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi fk5, a common question but it is not implemented (and I think not allowed by the IEC 61131-3).&lt;br/&gt;
You can:&lt;br/&gt;
1. use a function block and output all possible values&lt;br/&gt;
2. return a STRUCT of all possible values&lt;br/&gt;
3. Only return the maximal resolution Datatype and require the calling code to do an &lt;em&gt;&lt;em&gt;TO&lt;/em&gt;&lt;/em&gt;. Obviously this is limiting, as LREAL and LINT can hold numbers that the other can't.&lt;br/&gt;
4. write a separate function for each Datatype, eg anyTestFunction_AsReal(), anyTestFunction_AsLint()&lt;/p&gt;
&lt;p&gt;In practice I haven't found this a big limitation, as you have to think about what datatypes you're using anyway, and knowing that someone (me?) has taken the time to write a specific _AsReal() function rather than just hoping a generic typecast will fit is OK with me.&lt;/p&gt;
&lt;p&gt;Which do you think you'll use?&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Flexible variable type for functions: ANY_TO_xxx</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/8b09369d84/?limit=25#4792" rel="alternate"/><published>2020-02-27T14:14:25.953000Z</published><updated>2020-02-27T14:14:25.953000Z</updated><author><name>Anonymous</name><uri>https://forge.codesys.com/u/*anonymous/</uri></author><id>https://forge.codesys.comc707f33f8872e27842e235f09035e1bf63132933</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;&lt;em&gt;Originally created by:&lt;/em&gt; fk5&lt;/p&gt;
&lt;p&gt;(I accidentally posted this question in the v2.3 section instead of the v3.5 section)&lt;/p&gt;
&lt;p&gt;I was able to get the input of the function to accept any variable type, but I also want it to output into the same type as whatever is connected to it.&lt;br/&gt;
Is this possible? (Example: I'd like to modify this function to work regardless if dd is a REAL, INT, BYTE, ...)&lt;/p&gt;
&lt;p&gt;&lt;img alt="IMG: any_num_01.png" rel="nofollow" src="https://forum.codesys.com//download/file.php?id=4993"/&gt;&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>