GetDirectoryByIndex

TwinCAT TIA
Local File and directory access Folder

ns=2;s=DEPRAG Smart/Local/FileAndDirectoryAccess/DirectoryAccess/GetDirectoryByIndex

The command returns the properties of the directory with the specified index that is located in the specified directory.

Parameters:

    Index
    Unique index to retrieve the desired directory in the list.

Returns:

    GetDirectoryByIndex
    A variable of type OpcMethodReturnValueDirectoryInfo. The Result property contains the command-specific return values.
      Result
      A variable of the type DirectoryInfo. This contains all properties of the directory.
        Attributes
        An enumeration with the attributes of the file.
        The enumeration can have the following attributes. The attributes can also occur in combination.
        ReadOnly = 1
        Hidden = 2
        System = 4
        Directory = 16
        Archive = 32
        Device = 64
        Normal = 128
        Temporary = 256
        SparseFile = 512
        ReparsePoint = 1024
        Compressed = 2048
        Offline = 4096
        NotContentIndexed = 8192
        Encrypted = 16384
        IntegrityStream = 32768
        NoScrubData = 131072
        Exists
        Indicates whether the directory exists.
        Extension
        The extension of the folder name including the dot.

Examples:

In addition to the parameters already explained, the following variables must be created / transferred for the implementation in TwinCAT 3:

Beckhoff parameter:

    bDirectoryAccessGetDirectoryByIndex
    A boolean variable that can be used to trigger the execution of the GetDirectoryByIndex command.
    OutputDataDirectoryAccessGetDirectoryByIndex
    An instance of the "ST_GetDirectoryByIndexOutputData" in which the return value of the GetDirectoryByIndex method is written.
    hrDirectoryAccessGetDirectoryByIndex
    This can be used to monitor the execution of the command. Error codes have the type "HRESULT".
    fbDirectoryAccess
    An instance of the "FB_DirectoryAccess" function block supplied with the DEPRAG Smart library.
    sFullPath
    A STRING variable containing the full path of the directory.
    nIndex
    A DINT value that specifies the directory to retrieve from the list.
    ConnectionHandle
    "ConnectionHandle" received when establishing a connection between DEPRAG Smart Server and your OPC UA client.


VAR
     bDirectoryAccessGetDirectoryByIndex     : BOOL;
     OutputDataDirectoryAccessGetDirectoryByIndex  : ST_GetDirectoryByIndexOutputData;
     hrDirectoryAccessGetDirectoryByIndex    : HRESULT;

     fbDirectoryAccess : FB_DirectoryAccess;
END_VAR

hrDirectoryAccessGetDirectoryByIndex := fbDirectoryAccess.GetDirectoryByIndex(
              bExecute    := bDirectoryAccessGetDirectoryByIndex,
              ConnectionHandle  := depragSmartConnection.ConnectionHandle,
              sFullPath   := 'D:\Test',
              nIndex     := 0,
              OutputData   => OutputDataDirectoryAccessGetDirectoryByIndex);
IF hrDirectoryAccessGetDirectoryByIndex <> S_FALSE THEN 
     bDirectoryAccessGetDirectoryByIndex := FALSE;
END_IF
                                                    

For examples and explanations regarding the calls of nodes via Siemens TIA Portal please refer to the sub-menu "Siemens TIA Portal" in section "Getting Started".