<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to Create Txt file in column-wise</title><link href="https://forge.codesys.com/forge/talk/CODESYS-V2/thread/95372bfdee/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/CODESYS-V2/thread/95372bfdee/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/CODESYS-V2/thread/95372bfdee/</id><updated>2020-02-27T19:48:00.774000Z</updated><subtitle>Recent posts to Create Txt file in column-wise</subtitle><entry><title>Create Txt file in column-wise</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/95372bfdee/?limit=25#a977" rel="alternate"/><published>2020-02-27T19:48:00.774000Z</published><updated>2020-02-27T19:48:00.774000Z</updated><author><name>shooter</name><uri>https://forge.codesys.com/u/shooter/</uri></author><id>https://forge.codesys.comb9973b206dca767a3726fd09f2795ab27da9d326</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;put a comma in between the columns so it will be a CDF&lt;/p&gt;
&lt;p&gt;and check your string length strstring:string(3);&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Create Txt file in column-wise</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/95372bfdee/?limit=25#8da8" rel="alternate"/><published>2020-02-27T19:47:59.506000Z</published><updated>2020-02-27T19:47:59.506000Z</updated><author><name>Siavash-80</name><uri>https://forge.codesys.com/u/siavash-80/</uri></author><id>https://forge.codesys.com748e4d720dca0a3b5ff5dfb8c6ef8281f7b7b1cf</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;pnn hat geschrieben:&lt;/strong&gt;&lt;br/&gt;
you write to file var ay which doesn't contain CRLF, write strString instead&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Hi, &lt;/p&gt;
&lt;p&gt;Thanks for your reply, How can perform CRLF in CodeSys  . I solved the problem with "CONCAT" and "$R$N". And now I have problem how to save data in 2 columns in excel file. In such way that if I could plot each column.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Create Txt file in column-wise</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/95372bfdee/?limit=25#7828" rel="alternate"/><published>2020-02-27T19:47:58.220000Z</published><updated>2020-02-27T19:47:58.220000Z</updated><author><name>pnn</name><uri>https://forge.codesys.com/u/pnn/</uri></author><id>https://forge.codesys.com0fcc605dcb7979c8a489281c8af3b9342d55ac1d</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;you write to file var ay which doesn't contain CRLF, write strString instead&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Create Txt file in column-wise</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/95372bfdee/?limit=25#3695" rel="alternate"/><published>2020-02-27T19:47:54.579000Z</published><updated>2020-02-27T19:47:54.579000Z</updated><author><name>Siavash-80</name><uri>https://forge.codesys.com/u/siavash-80/</uri></author><id>https://forge.codesys.com2954e2ef1722d5e0bfec79b12ce115415404d585</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Dear All, &lt;/p&gt;
&lt;p&gt;I would like to save data in txt file for plotting by Matlab. Following code I am using but result is not that one I want I have shifted to right in each row: &lt;br/&gt;
PROGRAM PLC_PRG&lt;br/&gt;
VAR&lt;br/&gt;
    hFile: DWORD;&lt;br/&gt;
    szFilePath: STRING:= 'C:\ay.txt';&lt;br/&gt;
    wNewLine: ARRAY&lt;span&gt;[1..20]&lt;/span&gt; OF STRING;&lt;br/&gt;
    (&lt;em&gt;wNewLine:STRING;&lt;/em&gt;)&lt;br/&gt;
    dwWritten:DWORD;&lt;br/&gt;
    CloseFile: BOOL;&lt;br/&gt;
    ay:STRING;&lt;br/&gt;
    i: INT:= 1 ;&lt;br/&gt;
    strString:STRING;&lt;br/&gt;
    Lenght: INT;&lt;br/&gt;
    SizeoFile: DINT;&lt;br/&gt;
END_VAR&lt;/p&gt;
&lt;p&gt;hFile := SysFileOpen(szFilePath, 'a');&lt;/p&gt;
&lt;p&gt;WHILE (i &amp;lt;&amp;gt; 30) DO&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="nt"&gt;ay&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="nt"&gt;INT_TO_STRING&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;i&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;

&lt;span class="nt"&gt;dwWritten&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="nt"&gt;SysFileWrite&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;hFile&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nt"&gt;ADR&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;ay&lt;/span&gt;&lt;span class="o"&gt;),&lt;/span&gt; &lt;span class="nt"&gt;SIZEOF&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;ay&lt;/span&gt;&lt;span class="o"&gt;));&lt;/span&gt;
&lt;span class="nt"&gt;strString&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="nt"&gt;CONCAT&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;ay&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'$R$L'&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="nt"&gt;i&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="nt"&gt;i&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="nt"&gt;1&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;END_WHILE&lt;/p&gt;
&lt;p&gt;Lenght := LEN(strString);&lt;br/&gt;
(&lt;em&gt;Close the Opened File&lt;/em&gt;)&lt;br/&gt;
CloseFile :=  SysFileClose(hFile);&lt;br/&gt;
SizeoFile := SysFileGetSize(szFilePath);&lt;/p&gt;
&lt;p&gt;Result in ay.txt file I am looking for: &lt;br/&gt;
1   &lt;br/&gt;
         2 &lt;br/&gt;
               3&lt;br/&gt;
                       4 &lt;br/&gt;
                           5                                                                              &lt;br/&gt;
                                  6 &lt;br/&gt;
...30&lt;br/&gt;
RESULT I GOT:&lt;/p&gt;
&lt;p&gt;&lt;img alt="IMG: ay.png" rel="nofollow" src="https://forum.codesys.com//download/file.php?id=388"/&gt;&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>