File function

File functions allow you to manipulate local and remote files. The file functions support UNC Network path (for example “\\Server1\Share1\test.txt”). However it is recommended to write and read only files that reside inside the current project directory. To get the current Project directory you can use the function “GetPrjDir“. This function always returns the directory where the GpMainPj.xml file is located, always terminated with an “\”.

Please keep in mind that VisXpert uses C-Style string escaping. So you have to use double \ for an single \ in the resulting filename. The first backslash is the escape character, and the second the final character.

CopyDir

Declaration CopyDir(string src, string dst, bool fMove)
Function Copies the files from the source directory src to the destination directory dst if fMove is false, or moves the files from the source directory src to the target directory dst if fMove is true.
Example CopyDir(‘D:\\Data’, ‘X:\\BackupData’, false)

Copyfile

Declaration CopyFile(string srcFile, string dstFile)
Function Copies the source file srcFile to dstFile (destination file).
Cross Deletefile
Example CopyFile(‘C:\\DataLog.txt’,’C:\\TempProtocol.txt’, true)

CreateDir

Declaration CreateDir(string dir)
Function Creates the directory for you.
Cross Removedir
Example CreateDir(‘C:\\Data’)

Deletefile

Declaration DeleteFile(string file)
Function Deletes the file.
Cross Copyfile
Example DeleteFile(‘C:\\DataProtocol.txt’)

ExistFile

Declaration bool ExistFile (string file)
Function Determines whether the specified file file exists
Example Bool fExist
fExist := ExistFile(‘C:\\DataProtocol.txt’)

GetFileList

Declaration string GetFileList(string path)
Function Returns the files of the specified directory (path) separated with CR LF.
Cross GetFileTime
Example string s
s := GetFileList(‘C:\\TEMP*.*’)

GetFileTime

Declaration double ExistFile (string file)
Function Gets the timestamp of the last change to the specified file file.
Example Double ts
ts :=getFileTime(‘C:\\DataProtocol.txt’)

ReadTxt

Declaration string ReadTxt(string file)
Function Returns the contents of the file file as a string
Example String s
s := ReadTxt(‘D:\\Quantities.txt’)

RemoveDir

Declaration RemoveDir(string dir)
Function Delete the directory to you. The specified directory must be empty.
Cross CreateDir
Example RemoveDir(‘C:\\Data’)

WriteTxt

Declaration WriteTxt(string file, string s, bool fOverwrite)
Function Appends the string s to the file file file. If fOverwrite is true, an existing file is overwritten.
Example WriteTxt(‘D:\\Quantities.txt’, ‘Produced quantity: 230’, true)