Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.


Log in or register to post/reply in the forum.

File Management CR1000


Carlito Mar 31, 2009 04:23 PM

Hi All,

I'm having some trouble trying to write an especific file into CR1000. When I try to the OpenFile() command I don't know if thefile has been initated so i put the code below into the main program:

If NOT created Then
file = FileOpen("USR:Buffer.txt","w+",0)
FileWrite(file,"teste",0)
If (FileSize(file)>0)
created = true
EndIf
FileClose(file)
EndIf

Then I try to write something to the file with the FileWrite() command as in the code below:

file = FileOpen("USR:Buffer.txt","a+",0)
FileWrite(file,record,0)
SerialOut (COMRS232,"Bufferized: "+ record+". Filesize = "+ FileSize(file)+ "Created:"+created,"",0,100)
FileClose(file)

But what i got is that the file was never created and File size had never increased!

I tryed do configure in Device Config. the name of Buffer.txt as (3211,USR:Buffer.txt,0) but still got nothing.

Waiting for some help.

José Carlito de Oliveira Filho


jtrauntvein Mar 31, 2009 09:18 PM

Hello Carlito,

If the file creation was successful, the return value for FileOpen() will be a non-zero value. Otherwise, it will have a value of zero. The reason that your file size was not increasing is because you had specified a value of zero for the third parameter of FileWrite(). This third parameter specifies the size of the buffer that you are trying to write.

Regards,

Jon Trauntvein

Log in or register to post/reply in the forum.