<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to STRING conversions to DWORD</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/5fcee077e2/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Engineering/thread/5fcee077e2/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Engineering/thread/5fcee077e2/</id><updated>2025-02-02T12:28:42.971000Z</updated><subtitle>Recent posts to STRING conversions to DWORD</subtitle><entry><title>STRING conversions to DWORD</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/5fcee077e2/?limit=25#e6c9" rel="alternate"/><published>2025-02-02T12:28:42.971000Z</published><updated>2025-02-02T12:28:42.971000Z</updated><author><name>TimvH</name><uri>https://forge.codesys.com/u/timvh/</uri></author><id>https://forge.codesys.com873ab20f8ebeadfb0c78ea717c9c6808c195b0d1</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;I guess that the printer expects to receive an array of byte values. So where it is described that it expects to receive:&lt;br/&gt;
Hercules String : 1B4F513030311B7532626C61636B04&lt;br/&gt;
it actually expects to receive an array of bytes with the values 1B,4F,51,30,30, etc.&lt;br/&gt;
So what you can do is create an array of bytes and assign the byte value to each item in the array:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="kr"&gt;VAR&lt;/span&gt;
    &lt;span class="n"&gt;abyToSend&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;ARRAY&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;..&lt;/span&gt;&lt;span class="mi"&gt;99&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="kr"&gt;OF&lt;/span&gt; &lt;span class="kt"&gt;BYTE&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;abyToSend&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="o"&gt;#&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="n"&gt;B&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="o"&gt;//&lt;/span&gt; &lt;span class="n"&gt;ASCII&lt;/span&gt; &lt;span class="n"&gt;Escape&lt;/span&gt; &lt;span class="n"&gt;character&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;hexadecimal&lt;/span&gt; &lt;span class="n"&gt;representation&lt;/span&gt; &lt;span class="n"&gt;uses&lt;/span&gt; &lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="o"&gt;#&lt;/span&gt; &lt;span class="n"&gt;as&lt;/span&gt; &lt;span class="n"&gt;prefix&lt;/span&gt;
&lt;span class="n"&gt;abyToSend&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="o"&gt;#&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="n"&gt;F&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="o"&gt;//&lt;/span&gt; &lt;span class="n"&gt;ASCII&lt;/span&gt; &lt;span class="s"&gt;'O'&lt;/span&gt;
&lt;span class="n"&gt;abyToSend&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="o"&gt;#&lt;/span&gt;&lt;span class="mi"&gt;51&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="o"&gt;//&lt;/span&gt; &lt;span class="n"&gt;ASCII&lt;/span&gt; &lt;span class="s"&gt;'Q'&lt;/span&gt;
&lt;span class="n"&gt;abyToSend&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="o"&gt;#&lt;/span&gt;&lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="o"&gt;//&lt;/span&gt; &lt;span class="n"&gt;ASCII&lt;/span&gt; &lt;span class="s"&gt;'0'&lt;/span&gt;
&lt;span class="o"&gt;//&lt;/span&gt; &lt;span class="n"&gt;you&lt;/span&gt; &lt;span class="n"&gt;can&lt;/span&gt; &lt;span class="n"&gt;do&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="n"&gt;rest&lt;/span&gt; &lt;span class="n"&gt;yourself&lt;/span&gt;
&lt;span class="o"&gt;//&lt;/span&gt; &lt;span class="n"&gt;maybe&lt;/span&gt; &lt;span class="n"&gt;could&lt;/span&gt; &lt;span class="n"&gt;be&lt;/span&gt; &lt;span class="n"&gt;created&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="n"&gt;lot&lt;/span&gt; &lt;span class="n"&gt;smarter&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;but&lt;/span&gt; &lt;span class="n"&gt;gives&lt;/span&gt; &lt;span class="n"&gt;you&lt;/span&gt; &lt;span class="n"&gt;an&lt;/span&gt; &lt;span class="n"&gt;indication&lt;/span&gt; &lt;span class="n"&gt;how&lt;/span&gt; &lt;span class="n"&gt;to&lt;/span&gt; &lt;span class="n"&gt;handle&lt;/span&gt; &lt;span class="n"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Then with the serial communication (or TCP/IP?) you can send a message with the reference to the array (abyToSend) and the number of bytes to send (15 bytes for the string you gave as example).&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>STRING conversions to DWORD</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/5fcee077e2/?limit=25#2814" rel="alternate"/><published>2025-02-01T09:57:11.675000Z</published><updated>2025-02-01T09:57:11.675000Z</updated><author><name>bertcom</name><uri>https://forge.codesys.com/u/bertcom/</uri></author><id>https://forge.codesys.com205615dc19eca3b6f691f50795dbe1cf546c5aa9</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi rmaas, &lt;/p&gt;
&lt;p&gt;Do you have any explenation how to send it to Hercules?&lt;/p&gt;
&lt;p&gt;Thank you!&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>STRING conversions to DWORD</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/5fcee077e2/?limit=25#f849" rel="alternate"/><published>2025-02-01T09:57:08.018000Z</published><updated>2025-02-01T09:57:08.018000Z</updated><author><name>bertcom</name><uri>https://forge.codesys.com/u/bertcom/</uri></author><id>https://forge.codesys.com673b083745111ac6cbb99c98f75081f795dbcfab</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi rmaas, &lt;/p&gt;
&lt;p&gt;Do you have any explenation how to send it to Hercules?&lt;/p&gt;
&lt;p&gt;Thank you!&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>STRING conversions to DWORD</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/5fcee077e2/?limit=25#d197" rel="alternate"/><published>2025-01-31T10:14:51.223000Z</published><updated>2025-01-31T10:14:51.223000Z</updated><author><name>rmaas</name><uri>https://forge.codesys.com/u/rmaas/</uri></author><id>https://forge.codesys.com9693bcd79e39f6a7aa718abdb81f81ec7f9a8053</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;The '' characters in Codesys are there only to indicate it is a STRING type.&lt;br/&gt;
They are not actually added to the string, maybe you are adding them unintentionally in the concat function?&lt;/p&gt;
&lt;p&gt;You can send your data from Codesys to Hercules to verify...&lt;/p&gt;
&lt;p&gt;Another option is to send the data as an array of bytes instead of a string, with every byte representing 1 ASCII character. &lt;a href="https://www.ascii-code.com/" rel="nofollow"&gt;https://www.ascii-code.com/&lt;/a&gt;&lt;br/&gt;
This way you are 100% sure Codesys is not adding any unwanted characters.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>STRING conversions to DWORD</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/5fcee077e2/?limit=25#5207" rel="alternate"/><published>2025-01-30T17:21:23.659000Z</published><updated>2025-01-30T17:21:23.659000Z</updated><author><name>bertcom</name><uri>https://forge.codesys.com/u/bertcom/</uri></author><id>https://forge.codesys.coma0266ca4b63f61c4a17e9a2e835df4f31aa250e8</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;@trusty-suire,&lt;/p&gt;
&lt;p&gt;The problem is not encoding. The problem is that codesys ands ' ' to the string. And the printer can't handle these character.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>STRING conversions to DWORD</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/5fcee077e2/?limit=25#47b4" rel="alternate"/><published>2025-01-30T17:21:19.480000Z</published><updated>2025-01-30T17:21:19.480000Z</updated><author><name>bertcom</name><uri>https://forge.codesys.com/u/bertcom/</uri></author><id>https://forge.codesys.com5643d32ead5dcdddb0debd5019869a952ef01959</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;@trusty-suire,&lt;/p&gt;
&lt;p&gt;The problem is not encoding. The problem is that codesys ands ' ' to the string. And the printer can't handle these character.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>STRING conversions to DWORD</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/5fcee077e2/?limit=25#cfdc" rel="alternate"/><published>2025-01-30T16:17:21.195000Z</published><updated>2025-01-30T16:17:21.195000Z</updated><author><name>trusty-squire</name><uri>https://forge.codesys.com/u/trusty-squire/</uri></author><id>https://forge.codesys.com29f52dbb204e532fdacf0f1a875a66c3f40c5bab</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;I don't fully understand the issue, but if the encoding is a problem you can try testing with WSTRING datatype instead of STRING.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://content.helpme-codesys.com/en/CODESYS%20Development%20System/_cds_datatype_wstring.html" rel="nofollow"&gt;https://content.helpme-codesys.com/en/CODESYS%20Development%20System/_cds_datatype_wstring.html&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>STRING conversions to DWORD</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/5fcee077e2/?limit=25#8deb" rel="alternate"/><published>2025-01-29T09:57:45.224000Z</published><updated>2025-01-29T09:57:45.224000Z</updated><author><name>bertcom</name><uri>https://forge.codesys.com/u/bertcom/</uri></author><id>https://forge.codesys.comc2b71f56a18a6447055a54b9284d5953827686c3</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Good afternoon.&lt;/p&gt;
&lt;p&gt;I want to communicate with a Domino Industrial Printer using its Codenet protocol.&lt;br/&gt;
The printer wants a series of Hexadecimal characters with no spaces or '00' characters. &lt;br/&gt;
Because of that i chose the option to make the prefix and subfix for my code in a string. &lt;br/&gt;
I have y variable data in another string.&lt;/p&gt;
&lt;p&gt;With a complete program of a lot of CONCAT functions i eventually get the format of code that the printer accepts ( tested it with the hercules tool). &lt;/p&gt;
&lt;p&gt;Hercules String : 1B4F513030311B7532626C61636B04&lt;/p&gt;
&lt;p&gt;The problem is : Codesys adds automatically 'code' to the code to show it is a string.&lt;/p&gt;
&lt;p&gt;Codesys string : '1B4F513030311B7532626C61636B04' &lt;/p&gt;
&lt;p&gt;The printer does not understand this. My idea is to convert the string datatype to an LWORD. &lt;/p&gt;
&lt;p&gt;I have no idea how to do this. I random types in STRING_TO_DWORD, as return i get 0. That didn't worked. Also on internet the explenations around string converting in codesys are very limited.  &lt;/p&gt;
&lt;p&gt;If there in anyone who can explain me how to do it, i would appreciate it a lot !&lt;/p&gt;
&lt;p&gt;Thank you!&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>