fscanfPL()
Reads a file similar to fscanf() except changes to the current WinCC OA language before converting.
Synopsis
int fscanfPL(file f, string format, <type1> &var1 [, <type2>
&var2...]);
Parameter
| Parameter | Description |
|---|---|
| f | file to be read |
| format | format to be read |
| var1, var2, ... | target variables |
Return value
In the event of errors, the function returns -1 or EOF otherwise, the number of read characters.
Error
If incorrect data types are used or if a file is not open.
Description
Reads a file similar to fscanf() but changes to the current WinCC OA language before converting.
main()
{
file f;
int i;
dyn_float wert;
wert[1]=12.123;
wert[2]=8.0;
wert[3]=3.1;
f=fopen("C:/TEMP/TEST.TXT","w");
//Opens a file
for (i=1;i<=3;i++) fprintfPL(f,"%f ",wert[i]);
//Write float values
rewind(f);// Back to the start
for (i=1;i<=3;i++)
{
fscanfPL(f,"%f",wert[i]); // Read as a float
DebugN(wert[i]); // Output
}
fclose(f);
}
main()
{
file f;
int err;
time now = getCurrentTime(); //Returns the current time
int tDay,tMonth,tYear;
f=fopen("C:/TEMP/TEST.TXT","w"); //Creates a file for
writing
err=ferror(f); //searches for file errors
fprintfPL(f,"Heute ist : %d %d %d", day(now), month(now),
year(now)); //Writes "today is" + current date into a text file
//TEST.TXT
fclose(f); //Closes the file
f=fopen("C:/TEMP/TEST.TXT","r"); //Opens the file for
reading
fscanfPL(f,"Today is: %d %d %d",
tDay,tMonth,tYear); //Reads the current data from the text
file
DebugN(tDay,tMonth,tYear);
err=ferror(f);
fclose(f);
}
Assignment
File functions
Availability
CTRL
