<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to Create a string by extracting value from a file</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/4fc207d2b3/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Engineering/thread/4fc207d2b3/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Engineering/thread/4fc207d2b3/</id><updated>2022-06-26T12:01:32.039000Z</updated><subtitle>Recent posts to Create a string by extracting value from a file</subtitle><entry><title>Create a string by extracting value from a file</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/4fc207d2b3/?limit=25#884e/7c5e" rel="alternate"/><published>2022-06-26T12:01:32.039000Z</published><updated>2022-06-26T12:01:32.039000Z</updated><author><name>master-student</name><uri>https://forge.codesys.com/u/master-student/</uri></author><id>https://forge.codesys.com8b4d2f053d0bf15997a38eb85efb8e6791e48c2b</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Thanks, I am trying to use the GVL examples but I am getting the following error "C0077:  Unknown type: 'CAA_FILENAME'. any idea?&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Create a string by extracting value from a file</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/4fc207d2b3/?limit=25#884e/3be7" rel="alternate"/><published>2022-06-26T12:01:30.364000Z</published><updated>2022-06-26T12:01:30.364000Z</updated><author><name>master-student</name><uri>https://forge.codesys.com/u/master-student/</uri></author><id>https://forge.codesys.com4402fd47398a388f3343f55fe8ada7f42b13e866</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Thanks, I am trying to use the GVL examples but I am getting the following error "C0077:  Unknown type: 'CAA_FILENAME'. any idea?&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Create a string by extracting value from a file</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/4fc207d2b3/?limit=25#884e/9852" rel="alternate"/><published>2022-06-26T12:01:28.071000Z</published><updated>2022-06-26T12:01:28.071000Z</updated><author><name>master-student</name><uri>https://forge.codesys.com/u/master-student/</uri></author><id>https://forge.codesys.comf0ca99bca8303f64b5400ea0686b2014c72007c5</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Thanks, I am trying to use the GVL examples but I am getting the following error "C0077:  Unknown type: 'CAA_FILENAME'. any idea?&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Create a string by extracting value from a file</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/4fc207d2b3/?limit=25#884e/56c1" rel="alternate"/><published>2022-06-26T12:01:24.263000Z</published><updated>2022-06-26T12:01:24.263000Z</updated><author><name>master-student</name><uri>https://forge.codesys.com/u/master-student/</uri></author><id>https://forge.codesys.com6533974e59076fc9af8066281aa9214a6ed8ef85</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Thanks, I am trying to use the GVL examples but I am getting the following error "C0077:  Unknown type: 'CAA_FILENAME'. any idea?&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Create a string by extracting value from a file</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/4fc207d2b3/?limit=25#884e" rel="alternate"/><published>2022-06-25T14:46:52.216000Z</published><updated>2022-06-25T14:46:52.216000Z</updated><author><name>timvh</name><uri>https://forge.codesys.com/u/timvh/</uri></author><id>https://forge.codesys.com4c7551002de434b9f4823e1a9018c2894dc5d228</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;You can use the "Read" functionality. When you call this (after you opened the file succesfully), the result is written in the buffer you have assigned when you call the Read function. Then it reads the amount of the size of the buffer, of if the file is smaller than the buffer, the whole file. From this buffer, you can use other functions to find the string you are looking for.&lt;/p&gt;
&lt;p&gt;So in the example at the top, the variable "Data" will contain the contents you read from the file.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Create a string by extracting value from a file</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/4fc207d2b3/?limit=25#9362" rel="alternate"/><published>2022-06-25T14:46:48.673000Z</published><updated>2022-06-25T14:46:48.673000Z</updated><author><name>timvh</name><uri>https://forge.codesys.com/u/timvh/</uri></author><id>https://forge.codesys.combe0f7b0ada03e4975bc0d33c7f44c629cf152666</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;You can use the "Read" functionality. When you call this (after you opened the file succesfully), the result is written in the buffer you have assigned when you call the Read function. Then it reads the amount of the size of the buffer, of if the file is smaller than the buffer, the whole file. From this buffer, you can use other functions to find the string you are looking for.&lt;/p&gt;
&lt;p&gt;So in the example at the top, the variable "Data" will contain the contents you read from the file.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Create a string by extracting value from a file</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/4fc207d2b3/?limit=25#41c9/76e6" rel="alternate"/><published>2022-06-25T13:05:35.108000Z</published><updated>2022-06-25T13:05:35.108000Z</updated><author><name>master-student</name><uri>https://forge.codesys.com/u/master-student/</uri></author><id>https://forge.codesys.comce2e609bf37f5a0799c86a7abfe54c7f9d26ad31</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Thanks for the input. I tried working with CAA file and the examples but i did not managed to come up with a solution. I first opened a directory and then a opened file but can't copy a value to a string, out of it. Could you may be tell me what function should I use exactly use or an example for the problem? Thanks&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Create a string by extracting value from a file</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/4fc207d2b3/?limit=25#41c9" rel="alternate"/><published>2022-06-22T15:40:34.148000Z</published><updated>2022-06-22T15:40:34.148000Z</updated><author><name>paulpotat</name><uri>https://forge.codesys.com/u/paulpotat/</uri></author><id>https://forge.codesys.com54025c3228f82fbc0a1b78aa70bbe32ce85ca640</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hello,&lt;br/&gt;
I think it would be easier for you to use the &lt;a class="" href="https://content.helpme-codesys.com/en/libs/CAA%20File/Current/CAA-File/fld-CAA-File.html" rel="nofollow"&gt;&lt;em&gt;CAAFile&lt;/em&gt;&lt;/a&gt; library instead of &lt;em&gt;Sysfile&lt;/em&gt;.&lt;br/&gt;
The &lt;em&gt;File.Open&lt;/em&gt; FB of the CAA_File library will directly return a string with the content of your file. You can find examples &lt;a class="" href="https://content.helpme-codesys.com/en/libs/CAA%20File/Current/Examples.html" rel="nofollow"&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Create a string by extracting value from a file</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/4fc207d2b3/?limit=25#11de" rel="alternate"/><published>2022-06-22T14:20:56.670000Z</published><updated>2022-06-22T14:20:56.670000Z</updated><author><name>master-student</name><uri>https://forge.codesys.com/u/master-student/</uri></author><id>https://forge.codesys.comcde36db4461d4983a06344358e1aec5e8a0ab70f</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;I want to create a program to extract value from a file and create a sting (later I would want to use this string as an input value).&lt;/p&gt;
&lt;p&gt;&lt;img src="./attachment/value.JPG" width="50%"/&gt;&lt;/p&gt;
&lt;p&gt;Also i found this solution to open the file and read the values &lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="nt"&gt;VAR_INPUT&lt;/span&gt;
   &lt;span class="nt"&gt;FileName&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;STRING&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="s1"&gt;'/sys/bus/w1/devices/28-44260f1e64ff/w1_slave'&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="nt"&gt;END_VAR&lt;/span&gt;
&lt;span class="nt"&gt;VAR_OUTPUT&lt;/span&gt;
   &lt;span class="nt"&gt;Done&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;BOOL&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="nt"&gt;FALSE&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
   &lt;span class="nt"&gt;ErrCode&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;SysFile&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;SYS_FILE_STATUS&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="nt"&gt;SysFile&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;SYS_FILE_STATUS&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;FS_NO_FILE&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
   &lt;span class="nt"&gt;Data&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;ARRAY&lt;/span&gt;&lt;span class="cp"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="bp"&gt;..&lt;/span&gt;&lt;span class="nx nx-Member"&gt;MAX_BUFFER&lt;/span&gt;&lt;span class="cp"&gt;]&lt;/span&gt; &lt;span class="nt"&gt;OF&lt;/span&gt; &lt;span class="nt"&gt;BYTE&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
   &lt;span class="nt"&gt;BytesRead&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;__XWORD&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="nt"&gt;0&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="nt"&gt;END_VAR&lt;/span&gt;
&lt;span class="nt"&gt;VAR&lt;/span&gt;
   &lt;span class="nt"&gt;pResult&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;POINTER&lt;/span&gt; &lt;span class="nt"&gt;TO&lt;/span&gt; &lt;span class="nt"&gt;SysFile&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;RTS_IEC_RESULT&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
   &lt;span class="nt"&gt;FileHandle&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;SysFile&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;RTS_IEC_HANDLE&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
   &lt;span class="nt"&gt;pFileData&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;POINTER&lt;/span&gt; &lt;span class="nt"&gt;TO&lt;/span&gt; &lt;span class="nt"&gt;BYTE&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;Data&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="nt"&gt;END_VAR&lt;/span&gt;
&lt;span class="o"&gt;//&lt;/span&gt;&lt;span class="nt"&gt;try&lt;/span&gt; &lt;span class="nt"&gt;to&lt;/span&gt; &lt;span class="nt"&gt;open&lt;/span&gt; &lt;span class="nt"&gt;file&lt;/span&gt;
&lt;span class="nt"&gt;FileHandle&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="nt"&gt;SysFileOpen&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;szFile&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="nt"&gt;FileName&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nt"&gt;am&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="nt"&gt;AM_READ&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nt"&gt;pResult&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="nt"&gt;pResult&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="o"&gt;//&lt;/span&gt;&lt;span class="nt"&gt;verify&lt;/span&gt; &lt;span class="nt"&gt;found&lt;/span&gt; &lt;span class="nt"&gt;a&lt;/span&gt; &lt;span class="nt"&gt;file&lt;/span&gt;
&lt;span class="nt"&gt;IF&lt;/span&gt; &lt;span class="nt"&gt;FileHandle&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nt"&gt;SysFile&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;RTS_INVALID_HANDLE&lt;/span&gt; &lt;span class="nt"&gt;THEN&lt;/span&gt;
   &lt;span class="o"&gt;//&lt;/span&gt;&lt;span class="nt"&gt;no&lt;/span&gt; &lt;span class="nt"&gt;file&lt;/span&gt; &lt;span class="nt"&gt;found&lt;/span&gt;
   &lt;span class="nt"&gt;ErrCode&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="nt"&gt;SysFile&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;SYS_FILE_STATUS&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;FS_NO_FILE&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
   &lt;span class="nt"&gt;Done&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="nt"&gt;TRUE&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="nt"&gt;ELSE&lt;/span&gt;
   &lt;span class="o"&gt;//&lt;/span&gt;&lt;span class="nt"&gt;try&lt;/span&gt; &lt;span class="nt"&gt;to&lt;/span&gt; &lt;span class="nt"&gt;read&lt;/span&gt; &lt;span class="nt"&gt;file&lt;/span&gt; &lt;span class="nt"&gt;out&lt;/span&gt;
   &lt;span class="nt"&gt;BytesRead&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="nt"&gt;SysFileRead&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;FileHandle&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nt"&gt;pbyBuffer&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="nt"&gt;pFileData&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nt"&gt;ulSize&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="nt"&gt;MAX_BUFFER&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nt"&gt;pResult&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="nt"&gt;pResult&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;

   &lt;span class="o"&gt;//&lt;/span&gt;&lt;span class="nt"&gt;check&lt;/span&gt; &lt;span class="nt"&gt;if&lt;/span&gt; &lt;span class="nt"&gt;actually&lt;/span&gt; &lt;span class="nt"&gt;read&lt;/span&gt; &lt;span class="nt"&gt;any&lt;/span&gt; &lt;span class="nt"&gt;bytes&lt;/span&gt;
   &lt;span class="nt"&gt;IF&lt;/span&gt; &lt;span class="nt"&gt;BytesRead&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nt"&gt;0&lt;/span&gt; &lt;span class="nt"&gt;THEN&lt;/span&gt;
      &lt;span class="nt"&gt;ErrCode&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="nt"&gt;SysFile&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;SYS_FILE_STATUS&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;FS_OK&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
   &lt;span class="nt"&gt;ELSE&lt;/span&gt;
      &lt;span class="nt"&gt;ErrCode&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="nt"&gt;SysFile&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;SYS_FILE_STATUS&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;FS_NO_FILE&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
   &lt;span class="nt"&gt;END_IF&lt;/span&gt;
   &lt;span class="nt"&gt;Done&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="nt"&gt;TRUE&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="nt"&gt;END_IF&lt;/span&gt;
&lt;span class="o"&gt;//&lt;/span&gt;&lt;span class="nt"&gt;close&lt;/span&gt; &lt;span class="nt"&gt;file&lt;/span&gt;&lt;span class="o"&gt;!!!!&lt;/span&gt;
&lt;span class="nt"&gt;SysFileClose&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;FileHandle&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;&lt;img src="./attachment/Output.JPG" width="50%"/&gt;&lt;/p&gt;
&lt;p&gt;Please help.&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>