<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to File write question</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/4e4e0ac0f1/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Engineering/thread/4e4e0ac0f1/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Engineering/thread/4e4e0ac0f1/</id><updated>2020-02-27T13:51:59.328000Z</updated><subtitle>Recent posts to File write question</subtitle><entry><title>File write question</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/4e4e0ac0f1/?limit=25#e19e" rel="alternate"/><published>2020-02-27T13:51:59.328000Z</published><updated>2020-02-27T13:51:59.328000Z</updated><author><name>dFx</name><uri>https://forge.codesys.com/u/dfx/</uri></author><id>https://forge.codesys.comfe94b4d50cc1585ef1d683f0fa7bb62de5d9bc15</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;File operations are async. Meaning that they may last way more than one cycle till done.&lt;br/&gt;
Just pass the correct parameters when your xexecute is rising from 0 to 1. &lt;br/&gt;
Then you should not stop it till the done( may be error) flag. Otherwise you could have inconsistent file writings.&lt;/p&gt;
&lt;p&gt;On the exemple provided, the xexecute flag is not reseted because when it's done or when the file is not open for a write, the write function is not called.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>File write question</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/4e4e0ac0f1/?limit=25#4020" rel="alternate"/><published>2020-02-27T13:51:59.165000Z</published><updated>2020-02-27T13:51:59.165000Z</updated><author><name>KMor77</name><uri>https://forge.codesys.com/u/kmor77/</uri></author><id>https://forge.codesys.com7be8ba2c8c33f4d029604e1def3a56c565ad9f7f</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Yes I realized that the FB responds to the rising edge of the execute flag.  It seems the code before the write call would be executed needlessly every  program loop.&lt;/p&gt;
&lt;p&gt;would it be better to include a "IF filewrite.xExecute = FALSE" before defining the size, buffer address etc.?&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>File write question</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/4e4e0ac0f1/?limit=25#b99f" rel="alternate"/><published>2020-02-27T13:51:58.967000Z</published><updated>2020-02-27T13:51:58.967000Z</updated><author><name>timvh</name><uri>https://forge.codesys.com/u/timvh/</uri></author><id>https://forge.codesys.com49d79c548fd12db793f9d07986071eb80154b79d</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;You're right. Somewhere should also be a fileWrite(xExecute := FALSE);&lt;br/&gt;
Otherwise it will only write once.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>File write question</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/4e4e0ac0f1/?limit=25#2693" rel="alternate"/><published>2020-02-27T13:51:58.770000Z</published><updated>2020-02-27T13:51:58.770000Z</updated><author><name>KMor77</name><uri>https://forge.codesys.com/u/kmor77/</uri></author><id>https://forge.codesys.coma8df1c5217e4e25a8813a4ffc32a14b409b62da4</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;I have a simple question regarding writing to a file.&lt;/p&gt;
&lt;p&gt;The example in Codesys is &lt;/p&gt;
&lt;p&gt;2:  (&lt;em&gt; write text in the file &lt;/em&gt;)&lt;br/&gt;
    filewrite.hFile:=hFile;&lt;br/&gt;
    filewrite.pBuffer:=ADR(filestring);&lt;br/&gt;
    filesize1:=SIZEOF(filestring);&lt;br/&gt;
    filewrite.szSize:=filesize1;&lt;br/&gt;
    filewrite.udiTimeOut:=100000;                     (&lt;em&gt; 100ms Timeout &lt;/em&gt;)&lt;br/&gt;
    filewrite(xExecute:=TRUE);&lt;br/&gt;
    IF filewrite.xDone THEN&lt;br/&gt;
        uiDemoStatus:=uiDemoStatus+1;&lt;br/&gt;
    END_IF&lt;br/&gt;
    IF filewrite.xError THEN&lt;br/&gt;
        (&lt;em&gt; error handling&lt;/em&gt;)&lt;br/&gt;
        ;&lt;br/&gt;
    END_IF&lt;/p&gt;
&lt;p&gt;why isn't the write reinitialized each time during the program loop? It seems that you would never get to set the done flag.&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>