I am Using WinCCOA 3.14 on Win 7 64 Bit.
I got a question about file operations in WinCC. I am searching for a function like the SetEndOfFile function.
My Problem:
My Script is writing data to a file in a while loop. Before writing to the file I am setting the filepointer to the start of the file via fseek (f, 0, SEEK_SET);.
If my data has less bytes in this loop then in my last loop there are old bytes left in the file from the last writing operation. I want to set the end of file where I stopped writing in this loop to avoid problems with old bytes from the last loop.
See Code attached.
Code: Select all
main()
{
int err; // error code
const string fileName = "C:/TEMP/TEST.csv";
file f = fopen(fileName, "w");
err = ferror(f); //Output possible errors
if ( err )
{
DebugN("fopen Error");
return;
}
else
{
while(true) //
{
delay(1,500);
int speed;
dpGet("System1:Car1.speed",speed);
string data = "speed_in;"+speed+"\\n";
fseek (f, 0, SEEK_SET);
fputs(data, f);
fflush (f);
SetEndOfFile(f);
}
}
fclose(f);
}Is there a way to get SetEndOfFile() to work in WinCC or is there a similar function which works in WinCC?
Best regards,
Stefan Weigl