You are here: Technical References > Programming Languages > PLC Advanced Libraries > File Management Function Examples

File Management Function Examples

Following are several examples of how File Management functions may be used. The functions used include F_AOPEN, F_CLOSE, F_WOPEN, and FM_WRITE.

// Determine if this is a UNIX-based or Windows operating system and set the directory.
ID:= F_AOPEN('C:\Program Files\Kollmorgen\Kollmorgen Automation Suite\Sinope Runtime\Resources\http.conf');
IF ID > 0 THEN
OutputFile := '\' + FileName;
F_CLOSE(ID);
ELSE
OutputFile := FileName;
END_IF;

IF (AddFileExt = true) THEN
OutputFile := OutputFile + '.csv';
END_IF;
// Create a file for writing
FileID := F_WOPEN (OutputFile);
IF (FileID = 0) THEN
RETURN;
END_IF;
// Write header information to a file
HeaderStr := 'Time[ms],' + Header1 + '$R';
bStatus := FM_WRITE (FileID, HeaderStr);
IF (bStatus = false) THEN
F_CLOSE (FileID);
FileID := 0;
RETURN;
END_IF;

 


Stay Connected with Kollmorgen

Copyright © 2015 Kollmorgen™