DirectoryClose
Function Block - Closes an Open directory.
- Closing a directory releases its handle so it can be reused.
- Every directory opened with DirectoryOpen should be closed with
DirectoryClose.
Inputs
|
Input |
Data Type See Data Types. |
Range |
Unit |
Default |
Description |
|---|---|---|---|---|---|
|
Execute |
BOOL |
FALSE, TRUE |
N/A |
No default |
On the rising edge, request to close a directory. |
|
ID |
UDINT |
No range |
N/A |
No default |
The ID of the open directory returned by DirectoryOpen. |
Outputs
|
Output |
Data Type See Data Types. |
Range |
Unit |
Description |
|---|---|---|---|---|
|
Done |
BOOL |
FALSE, TRUE |
N/A |
If TRUE, the command completed successfully. |
|
Error |
BOOL |
FALSE, TRUE |
N/A |
If TRUE, an error has occurred. |
|
ErrorID |
DINT |
Enumerated |
N/A |
|
FBD Language Example
FFLD Language Example
IL Language Example
Not available.
ST Language Example
CASE StepCounter OF
0: Inst_DirectoryOpen(TRUE, 'logs', '*.log', DIR_OPTION_FILES + DIR_OPTION_GLOB); IF Inst_DirectoryOpen.Done THEN
MyDirID := Inst_DirectoryOpen.ID; Inst_DirectoryOpen(FALSE, '', '', 0); StepCounter := StepCounter + 1;
END_IF; 1:
Inst_DirectoryRead(TRUE, MyDirID); StepCounter := StepCounter + 1; 2: Inst_DirectoryRead(TRUE, MyDirID);
IF Inst_DirectoryRead.Done THEN
IF Inst_DirectoryRead.ListDone THEN
// No more entries - move on to next step closing the directory Inst_DirectoryRead(FALSE, 0); StepCounter := StepCounter + 1; ELSE
EntryName := Inst_DirectoryRead.Entry.Name; IsDir := Inst_DirectoryRead.Entry.IsDirectory;
// Keep StepCounter unchanged so that return and read the next entry
Inst_DirectoryRead(FALSE, 0); END_IF; END_IF; 3: Inst_DirectoryClose(TRUE, MyDirID); StepCounter := StepCounter + 1; 4:
Inst_DirectoryClose(TRUE, MyDirID);
IF Inst_DirectoryClose.Done THEN
Inst_DirectoryClose(FALSE, 0); StepCounter := StepCounter + 1; END_IF; END_CASE;







