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
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