<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to How to write variable by name</title><link href="https://forge.codesys.com/forge/talk/CODESYS-V2/thread/577aa75397/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/CODESYS-V2/thread/577aa75397/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/CODESYS-V2/thread/577aa75397/</id><updated>2024-06-04T07:28:06.621000Z</updated><subtitle>Recent posts to How to write variable by name</subtitle><entry><title>How to write variable by name</title><link href="https://forge.codesys.com/forge/talk/CODESYS-V2/thread/577aa75397/?limit=25#c665" rel="alternate"/><published>2024-06-04T07:28:06.621000Z</published><updated>2024-06-04T07:28:06.621000Z</updated><author><name>Automa</name><uri>https://forge.codesys.com/u/automa/</uri></author><id>https://forge.codesys.com91037532cbb4c223ce63901f7a44e0333640b895</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;It has been a few years since this topic. Any solutions?&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>How to write variable by name</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/577aa75397/?limit=250#10c5" rel="alternate"/><published>2020-02-27T20:05:31.197000Z</published><updated>2020-02-27T20:05:31.197000Z</updated><author><name>Hermsen</name><uri>https://forge.codesys.com/u/hermsen/</uri></author><id>https://forge.codesys.com0ef8cc282c6fb16f599af86ec6447788581a20c4</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Bump!&lt;/p&gt;
&lt;p&gt;I am also very interested in this Technique. I see possibilities in combining this with a protocol format like JSON would be very useful.&lt;br/&gt;
E.g. finding a varname out of a file and searching for it in the runtime and read/write it.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>How to write variable by name</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/577aa75397/?limit=25#a794" rel="alternate"/><published>2020-02-27T20:05:29.887000Z</published><updated>2020-02-27T20:05:29.887000Z</updated><author><name>zorgoz</name><uri>https://forge.codesys.com/u/zorgoz/</uri></author><id>https://forge.codesys.com8db6b1fc7fbe8b42aa840f8ee4baad47d89a6930</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;shooter hat geschrieben:&lt;/strong&gt;&lt;br/&gt;
you can use pointers to find where a var is located.&lt;br/&gt;
please have a look at &lt;a class="" href="http://www.oscat.de" rel="nofollow"&gt;http://www.oscat.de&lt;/a&gt; for ways to do this.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;I have looked trougd OSCAT allready. Which OSCAT POU can find a variable's address using the variable name?&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>How to write variable by name</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/577aa75397/?limit=25#675f" rel="alternate"/><published>2020-02-27T20:05:26.197000Z</published><updated>2020-02-27T20:05:26.197000Z</updated><author><name>shooter</name><uri>https://forge.codesys.com/u/shooter/</uri></author><id>https://forge.codesys.com44e2ab50465e49124f9788a83c7cce21b24eb39c</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;you can use pointers to find where a var is located.&lt;br/&gt;
please have a look at  w &lt;a class="" href="http://www.oscat.de" rel="nofollow"&gt;www.oscat.de&lt;/a&gt; w  for ways to do this.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>How to write variable by name</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/577aa75397/?limit=25#5e77" rel="alternate"/><published>2020-02-27T20:05:24.884000Z</published><updated>2020-02-27T20:05:24.884000Z</updated><author><name>zorgoz</name><uri>https://forge.codesys.com/u/zorgoz/</uri></author><id>https://forge.codesys.com79b975fca073d0d5e0f3793afc1b61b1313e0921</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;What I have done is that I made my own symbol file from symxml. As there is a function that can return the starting address of the memory areas, I am storing in binary format in my file the symbol name, the memory area index, area relative memory offset and a code for the variable type (I am expanding all arrays and structures as needed even if they are not expanded in symxml). At PLC startup I am loading the content from this file into an array in memory. When I need to change a variable by name, I look for it in this array. As I know the type, I can now easily calculate the address, and it is now simple to set it.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>How to write variable by name</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/577aa75397/?limit=25#1b33" rel="alternate"/><published>2020-02-27T20:05:20.640000Z</published><updated>2020-02-27T20:05:20.640000Z</updated><author><name>shooter</name><uri>https://forge.codesys.com/u/shooter/</uri></author><id>https://forge.codesys.coma92526f041a2764a762ffbe1e8210054b1a0a8f1</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;if the names are always same (only the number is different please use an array and get the number from the string.&lt;br/&gt;
if the names are all different and you do not want to use pointers, make an big array with all the names and a for next loop to find every string, and update the value&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>How to write variable by name</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/577aa75397/?limit=25#87af" rel="alternate"/><published>2020-02-27T20:05:19.164000Z</published><updated>2020-02-27T20:05:19.164000Z</updated><author><name>Anonymous</name><uri>https://forge.codesys.com/u/*anonymous/</uri></author><id>https://forge.codesys.com60d6f4ee43e2e74351552fa34fe940083442e1d5</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;Yes, I see now that CASE needs a number in IEC61131.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>How to write variable by name</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/577aa75397/?limit=25#857a" rel="alternate"/><published>2020-02-27T20:05:17.843000Z</published><updated>2020-02-27T20:05:17.843000Z</updated><author><name>zorgoz</name><uri>https://forge.codesys.com/u/zorgoz/</uri></author><id>https://forge.codesys.com36f29d0985560c0fa5cbf185db1d146e8b3db1a1</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;scott_cunningham hat geschrieben:&lt;/strong&gt;&lt;br/&gt;
I think you will need a big case statement. (Tip - Use MS Excel to build you case statement lines).  When you send the file, the variable name would be a string for the case statement.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Thank you. The "" I was hoping not to need  But if I have to stick to that, I was also thinking of generating it. &lt;/p&gt;
&lt;p&gt;Anyway, CASE itself looks not to be an option, as when I tried to use it with strings, I got the error message, that .&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>How to write variable by name</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/577aa75397/?limit=25#71e2" rel="alternate"/><published>2020-02-27T20:05:14.137000Z</published><updated>2020-02-27T20:05:14.137000Z</updated><author><name>Anonymous</name><uri>https://forge.codesys.com/u/*anonymous/</uri></author><id>https://forge.codesys.comcb5fe4d0b4e853647755f9157ecd1ef28d5ed91b</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;I think you will need a big case statement. (Tip - Use MS Excel to build you case statement lines).  When you send the file, the variable name would be a string for the case statement.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>How to write variable by name</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/577aa75397/?limit=25#329e" rel="alternate"/><published>2020-02-27T20:05:12.784000Z</published><updated>2020-02-27T20:05:12.784000Z</updated><author><name>zorgoz</name><uri>https://forge.codesys.com/u/zorgoz/</uri></author><id>https://forge.codesys.com0b44462717007bb9935079649f98696ccb3ab436</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;shooter hat geschrieben:&lt;/strong&gt;&lt;br/&gt;
you can NOT change variable names, however in an array you can store any names set and the values too.&lt;br/&gt;
or you can just put them in designated places in an array&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Hello, &lt;br/&gt;
I don't want to change the name of a variable, only the value.&lt;br/&gt;
Ok. This is one option I was thinking about. Although it has some drawbacks. First of all, in my case the high number (200-300) of variables makes this approach error prone.&lt;/p&gt;
&lt;p&gt;I was thinking to get the address of the variable by parsing the symxml.SYM_XML symbol table. It is a promising approach. Still, it's content looks confusing. The SymbolVarList/Var/@Offset looks correct but relative to SysLibGetAddress(DATAID_GLOBVARS), but these are not globals. And the segment base addresses in the symxml look totally unrelated to the base address returned by SysLibGetAddress. See attachment.&lt;br/&gt;
Do you have any idea how to interpret symxml correctly?&lt;/p&gt;
&lt;p&gt;&lt;img alt="IMG: image4249.png" rel="nofollow" src="https://forum.codesys.com//download/file.php?id=2262"/&gt;&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>