DirList (FB; Prefix fildls) ¶ FUNCTION_BLOCK DirList EXTENDS CBM.ETrig This function reads directory entries. The function block needs a valid handle which identifies the directory as a transfer parameter. The information is written to structure ” deDirEntry ” of type ” FILE_DIR_ENTRY ”. If the function block cannot find any further entries the error message ” ERROR.NO_MORE_ENTRIES ” is generated and the entries in the structure ” deDirEntry ” are deleted. InOut: Scope Name Type Comment Input hDir CAA.HANDLE Directory handle Output eError ERROR Local library error ID (5106 - FILE_NO_MORE_ENTRIES: no further entries available) deDirEntry FILE_DIR_ENTRY Directory entry
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
Library Reference ¶ This is a dictionary of all referenced libraries and their name spaces. CAA Async Manager Extern ¶ Library Identification ¶ Placeholder: CAA Async Manager Default Resolution: CAA Async Manager Extern, * (CAA Technical Workgroup) Namespace: ASM Library Properties ¶ LinkAllContent: False Optional: False QualifiedOnly: True SystemLibrary: False Key: CAA Async Manager CAA Behaviour Model ¶ Library Identification ¶ Placeholder: CAA Behaviour Model Default Resolution: CAA Behaviour Model, * (CAA Technical Workgroup) Namespace: CBM Library Properties ¶ LinkAllContent: False Optional: False QualifiedOnly: True SystemLibrary: False Key: CAA Behaviour Model CAA Ressource Manager Extern ¶ Library Identification ¶ Placeholder: CAA ResMan Default Resolution: CAA Ressource Manager Extern, * (CAA Technical Workgroup) Namespace: RSM Library Properties ¶ LinkAllContent: False Optional: False QualifiedOnly: True SystemLibrary: False Key: CAA ResMan CAA Tick Extern ¶ Library Identification ¶ Placeholder: CAA Tick Default Resolution: CAA Tick Extern, * (CAA Technical Workgroup) Namespace: TICKS Library Properties ¶ LinkAllContent: False Optional: False QualifiedOnly: True SystemLibrary: False Key: CAA Tick CAA TickUtil Extern ¶ Library Identification ¶ Placeholder: CAA TickUtil Default Resolution: CAA TickUtil Extern, * (CAA Technical Workgroup) Namespace: TICKU Library Properties ¶ LinkAllContent: False Optional: False QualifiedOnly: True SystemLibrary: False Key: CAA TickUtil CAA Types Extern ¶ Library Identification ¶ Placeholder: CAA Types Default Resolution: CAA Types Extern, * (CAA Technical Workgroup) Namespace: CAA Library Properties ¶ LinkAllContent: False Optional: False QualifiedOnly: True SystemLibrary: False Key: CAA Types
ListBase (FB) ¶ FUNCTION_BLOCK ListBase IMPLEMENTS ISimpleList , IListHelper Properties: HeadElem ListIsEmpty ListSize TailElem Structure: HeadElem (Property) ListIsEmpty (Property) ListSize (Property) TailElem (Property)
TypedList (FB) ¶ FUNCTION_BLOCK TypedList EXTENDS ListBase IMPLEMENTS ITypedList Properties: HeadElem , inherited from ListBase ListIsEmpty , inherited from ListBase ListSize , inherited from ListBase TailElem , inherited from ListBase Methods: AppendElem InsertElem PopBackElem PopElem PushElem RemoveElem Structure: AppendElem (Method) InsertElem (Method) PopBackElem (Method) PopElem (Method) PushElem (Method) RemoveElem (Method)