This will query if a file already exists.
Input:
name : STRING
Name of the file to query. Both absolute and relative paths are allowed.
Returns: BOOL
TRUE:
|
File does exist.
|
FALSE:
|
File does not exist.
|
Declaration:
FUNCTION fsFileExists : BOOL;
VAR_INPUT
name : STRING;
END_VAR;
Example:
...
IF fsFileExists(name := "gpslog.dat") THEN
fd := fsFileOpen(name := "gpslog.dat");
ELSE
fd := fsFileCreate(name := "gpslog.dat");
END_IF;
IF fsFileStatus(fd := fd) = 0 THEN
...
fsFileWrite(fd := fd, buffer := ADDR(gps.latitude), length := SIZEOF(gps.latitude));
fsFileWrite(fd := fd, buffer := ADDR(gps.longitude), length := SIZEOF(gps.longitude));
...
fsFileClose(fd := fd);
ELSE
...
END_IF;
...
|