Global Variables ¶ CAA_Globale_Constants (GVL)
CAA_Globale_Constants (GVL) ¶ library specific property constants InOut: Scope Name Type Initial Constant gc_PDIRNAME WORD 1 gc_PRENAME WORD 2 gc_PCOPY WORD 3 gc_PSETATTRIBUTE WORD 4 gc_PFILENAME83 WORD 100 gc_PCAPITALLETTERS WORD 101 gc_PABSOLUTEPATH WORD 200 gc_PDRIVELETTER WORD 201 gc_PNETWORKDRIVES WORD 300
Structs ¶ FILE_DIR_ENTRY (Struct)
FILE_DIR_ENTRY (STRUCT) ¶ TYPE FILE_DIR_ENTRY : STRUCT This data structure holds information of a directory entry. It is filled by FILE.DirList for every entry in the open directory by sequential call. InOut: Name Type Comment sEntry CAA.FILENAME Name of directory or file szSize CAA.SIZE File size xDirectory BOOL Directory or file: TRUE: directory, FALSE: file xExclusive BOOL Access mode on file: TRUE: exclusive access mode, FALSE: multiple access mode possible dtLastModification DT Date and time of last modification, e.g. 2006-05-08-00:00:00
Examples (GVL) ¶ Directory ¶ (* example of how to use the CAA_FILE-library - directory function blocks *) PROGRAM DIR_PRG VAR xDirInit : BOOL := FALSE ; uiDirState : UINT := 0 ; sDirNewName : CAA_FILENAME := './TestDirectory' ; sDirNextName : CAA_FILENAME := './NewDirectory' ; hDir : CAA_HANDLE ; deNewDirectory : FILE_DIR_ENTRY ; fildcr : FILE.DirCreate ; fildop : FILE.DirOpen ; fildcl : FILE.DirClose ; fildls : FILE.DirList ; fildrn : FILE.DirRename ; fildrm : FILE.DirRemove ; END_VAR IF NOT xDirInit THEN fildcr ( xExecute := FALSE ); fildcl ( xExecute := FALSE ); fildls ( xExecute := FALSE ); fildrm ( xExecute := FALSE ); xDirInit := TRUE ; uiDirState := 0 ; ELSE CASE uiDirState OF 0 : (* create a new directory *) fildcr.sDirName := sDirNewName ; fildcr.xParent := FALSE ; fildcr ( xExecute := TRUE ); IF fildcr.xDone THEN uiDirState := 1 ; END_IF IF fildcr.xError THEN (* error handling*) ; END_IF 1 : (* open directory *) fildop.sDirName := sDirNewName ; fildop ( xExecute := TRUE ); IF fildop.xDone THEN hDir := fildop.hDir ; uiDirState := 2 ; END_IF IF fildop.xError THEN (* error handling*) ; END_IF 2 : (* get directory property list *) fildls.hDir := hDir ; fildls ( xExecute := TRUE ); IF fildls.xDone THEN deNewDirectory.sEntry := fildls.deDirEntry.sEntry ; deNewDirectory.szSize := fildls.deDirEntry.szSize ; deNewDirectory.xDirectory := fildls.deDirEntry.xDirectory ; deNewDirectory.xExclusive := fildls.deDirEntry.xExclusive ; deNewDirectory.dtLastModification := fildls.deDirEntry.dtLastModification ; uiDirState := 3 ; END_IF IF fildop.xError THEN (* error handling*) ; END_IF 3 : (* close directory *) fildcl.hDir := hDir ; fildcl ( xExecute := TRUE ); IF fildcl.xDone THEN uiDirState := 4 ; END_IF IF fildcl.xError THEN (* error handling*) ; END_IF 4 : (* rename directory*) fildrn.sDirNameOld := sDirNewName ; fildrn.sDirNameNew := sDirNextName ; fildrn ( xExecute := TRUE ); IF fildrn.xDone THEN uiDirState := 5 ; END_IF IF fildrn.xError THEN (* error handling*) ; END_IF 5 : (* remove directory*) fildrm.sDirName := sDirNextName ; fildrm.udiTimeOut := 100000 ; (* 100ms TimeOut *) fildrm.xRecursive := FALSE ; fildrm ( xExecute := TRUE ); IF fildrm.xDone THEN uiDirState := 6 ; END_IF IF fildrm.xError THEN (* error handling*) ; END_IF 6 : (* end of example*) ; END_CASE END_IF File - Standard ¶ (* example of how to use the CAA_FILE-library - file standard function blocks *) PROGRAM FILE_STANDARD_PRG VAR xFileStdInit : BOOL := FALSE ; uiFileStdState : UINT := 0 ; sFileName : CAA_FILENAME := 'TestFile.txt' ; hFile : CAA_HANDLE ; sFileTestString : STRING := 'Hello caa library user' ; sFileString : STRING := '' ; szFileSize1 : CAA_SIZE := 0 ; szFileSize2 : CAA_SIZE := 0 ; filop : FILE.Open ; filwr : FILE.Write ; filrd : FILE.Read ; filcl : FILE.Close ; END_VAR IF NOT xFileStdInit THEN filop ( xExecute := FALSE ); filcl ( xExecute := FALSE ); filwr ( xExecute := FALSE ); filrd ( xExecute := FALSE ); xFileStdInit := TRUE ; uiFileStdState := 0 ; ELSE CASE uiFileStdState OF 0 : (* create a new file *) filop.sFileName := sFileName ; filop.eFileMode := FILE_MRDWR ; filop.xExclusive := TRUE ; filop ( xExecute := TRUE ); IF filop.xDone THEN hFile := filop.hFile ; uiFileStdState := 1 ; END_IF IF filop.xError THEN (* error handling*) ; END_IF 1 : (* write text in the file *) filwr.hFile := hFile ; filwr.pBuffer := ADR ( sFileTestString ); szFileSize1 := SIZEOF ( sFileTestString ); filwr.szSize := szFileSize1 ; filwr.udiTimeOut := 100000 ; (* 100ms Timeout *) filwr ( xExecute := TRUE ); IF filwr.xDone THEN uiFileStdState := 2 ; END_IF IF filwr.xError THEN (* error handling*) ; END_IF 2 : (* read file - TestFile.txt*) filrd.hFile := hFile ; filrd.udiTimeOut := 100000 ; (* 100ms Timeout *) filrd.pBuffer := ADR ( sFileString ); filrd.szBuffer := 255 ; filrd ( xExecute := TRUE ); IF filrd.xDone THEN szFileSize2 := filrd.szSize ; IF szFileSize2 = szFileSize1 THEN uiFileStdState := 3 ; ELSE (* error handling*) ; END_IF END_IF IF filrd.xError THEN (* error handling*) ; END_IF 3 : (* close file - TestFile.txt *) filcl.hFile := hFile ; filcl ( xExecute := TRUE ); IF filcl.xDone THEN uiFileStdState := 4 ; END_IF IF filcl.xError THEN (* error handling*) ; END_IF 4 : (* end of example *) ; END_CASE END_IF File - Modification ¶ (* example of how to use the CAA_FILE-library - file change function blocks *) PROGRAM FILE_CHANGE_PRG VAR xFileChgInit : BOOL := FALSE ; uiFileChgState : UINT := 0 ; sFileOldName : CAA_FILENAME := 'TestFile.txt' ; sFileNewName : CAA_FILENAME := 'NewFile.txt' ; szCopiedFileSize : CAA_SIZE := 0 ; filcp : FILE.Copy ; filrn : FILE.Rename ; fildl : FILE.Delete ; END_VAR IF NOT xFileChgInit THEN fildl ( xExecute := FALSE ); filrn ( xExecute := FALSE ); filcp ( xExecute := FALSE ); xFileChgInit := TRUE ; uiFileChgState := 0 ; ELSE CASE uiFileChgState OF 0 : (*copy file *) filcp.sFileNameSource := sFileNewName ; filcp.sFileNameDest := 'DestFile.txt' ; filcp.udiTimeOut := 100000 ; (* 100ms Timeout *) filcp.xOverWrite := TRUE ; (* overwrite the existing file *) filcp ( xExecute := TRUE ); IF filcp.xDone THEN szCopiedFileSize := filcp.szSize ; uiFileChgState := 1 ; END_IF IF filcp.xError THEN (* error handling*) ; END_IF 1 : (* rename file *) filrn.sFileNameOld := 'DestFile.txt' ; filrn.sFileNameNew := sFileNewName ; filrn ( xExecute := TRUE ); IF filrn.xDone THEN uiFileChgState := 2 ; END_IF IF filrn.xError THEN (* error handling*) ; END_IF 2 : (* delete file *) fildl.sFileName := sFileNewName ; fildl ( xExecute := TRUE ); IF fildl.xDone THEN uiFileChgState := 3 ; END_IF IF fildl.xError THEN (* error handling*) ; END_IF 3 : (* end of example*) ; END_CASE END_IF File – internal pointer ¶ (* example of how to use the CAA_FILE-library - file position function blocks *) PROGRAM FILE_POINT_PRG VAR xFilePosInit : BOOL := FALSE ; uiFilePosState : UINT := 0 ; udiActualPosition : UDINT := 0 ; udiActualEoFPosition : UDINT := 0 ; sFileName : CAA_FILENAME := 'TestFile.txt' ; hFile : CAA_HANDLE ; filop : FILE.Open ; filcl : FILE.Close ; filgp : FILE.GetPos ; filsp : FILE.SetPos ; fileof : FILE.EOF ; END_VAR IF NOT xFilePosInit THEN filop ( xExecute := FALSE ); filcl ( xExecute := FALSE ); filgp ( xExecute := FALSE ); filsp ( xExecute := FALSE ); fileof ( xExecute := FALSE ); xFilePosInit := TRUE ; uiFilePosState := 0 ; ELSE CASE uiFilePosState OF 0 : (* open file *) filop.sFileName := sFileName ; filop.eFileMode := FILE_MRDWR ; filop.xExclusive := TRUE ; filop ( xExecute := TRUE ); IF filop.xDone THEN hFile := filop.hFile ; uiFilePosState := 1 ; END_IF IF filop.xError THEN (* error handling*) ; END_IF 1 : (* get actual internal positon file pointer *) filgp.hFile := hFile ; filgp ( xExecute := TRUE ); IF filgp.xDone THEN udiActualPosition := filgp.udiPos ; uiFilePosState := 2 ; END_IF IF filgp.xError THEN (* error handling*) ; END_IF 2 : (* query - end of file is reached *) fileof.hFile := hFile ; fileof ( xExecute := TRUE ); IF fileof.xDone THEN IF fileof.xEOF THEN udiActualEoFPosition := udiActualPosition ; END_IF uiFilePosState := 3 ; END_IF IF filgp.xError THEN (* error handling*) ; END_IF 3 : (* set the internal positon file pointer *) filsp.hFile := hFile ; filsp.udiPos := udiActualEoFPosition - 5 ; IF filsp.udiPos < 0 THEN filsp.udiPos := 0 ; END_IF filsp ( xExecute := TRUE ); IF filsp.xDone THEN uiFilePosState := 4 ; END_IF IF filsp.xError THEN (* error handling*) ; END_IF 4 : (* close file *) filcl.hFile := hFile ; filcl ( xExecute := TRUE ); IF filcl.xDone THEN uiFilePosState := 5 ; END_IF IF filcl.xError THEN (* error handling*) ; END_IF 5 : (* end of example*) ; END_CASE END_IF File – Properties ¶ (* example of how to use the CAA_FILE-library - file property function blocks *) PROGRAM FILE_PROP_PRG VAR xFilePropInit : BOOL := FALSE ; uiFilePropState : UINT := 0 ; sFileName : CAA_FILENAME := 'TestFile.txt' ; hFile : CAA_HANDLE ; szFileSize : CAA_SIZE := 0 ; dtLastFileMod : DT ; sLastFileModification : STRING := '' ; filop : FILE.Open ; filcl : FILE.Close ; filsa : FILE.SetAttribute ; filgs : FILE.GetSize ; filgt : FILE.GetTime ; END_VAR IF NOT xFilePropInit THEN filop ( xExecute := FALSE ); filcl ( xExecute := FALSE ); filsa ( xExecute := FALSE ); filgs ( xExecute := FALSE ); filgt ( xExecute := FALSE ); xFilePropInit := TRUE ; uiFilePropState := 0 ; ELSE CASE uiFilePropState OF 0 : (* get file size *) filgs.sFileName := sFileName ; filgs ( xExecute := TRUE ); IF filgs.xDone THEN szFileSize := filgs.szSize ; uiFilePropState := 1 ; END_IF IF filgs.xError THEN Attributes: qualified_only InOut: Scope Name Type Initial Constant iDummyforLibDocuCAAFile INT 99
Library Information ¶ GetLibVersion (Function) GetLibVersionNumber (Function) IsLibReleased (Function)
GetLibVersion (FUN) ¶ FUNCTION GetLibVersion : VERSION This function has been automatically generated from the project information. InOut: Scope Name Type Return GetLibVersion VERSION
GetLibVersionNumber (FUN) ¶ FUNCTION GetLibVersionNumber : DWORD This function has been automatically generated from the project information. InOut: Scope Name Type Return GetLibVersionNumber DWORD
IsLibReleased (FUN) ¶ FUNCTION IsLibReleased : BOOL This function has been automatically generated from the project information. InOut: Scope Name Type Return IsLibReleased BOOL
File and Project Information ¶ Scope Name Type Content FileHeader creationDateTime date 24.07.2019, 08:29:27 companyName string 3S-Smart Software Solutions GmbH libraryFile CAA_FILE.library primaryProject True productName CODESYS productProfile CODESYS V3.5 SP15 contentFile CAA_FILE.clean.json version version 2.0.0.0 ProjectInformation OnlineHelp bool True Released True LastModificationDateTime date 24.07.2019, 08:29:24 LibraryCategories library-category-list Intern|CAA|System Author string 3S - Smart Software Solutions GmbH Company CAA Technical Workgroup DefaultNamespace FILE Description See: Description DocFormat reStructuredText LanguageModelAttribute qualified-access-only Placeholder CAA File Project CAA_FILE Title CAA File Version version 3.5.15.0