Hitachi

JP1 Version 11 JP1/Script Description and Reference (For Windows Systems)


8.5.17 GetFileAttribute or GetFileAttr (get folder or file attributes)

Purpose

Gets folder or file attributes.

In JP1/Script 07-50 or later, the command supports large files.

Syntax
GetFileAttribute (PathName, AttrArrayBuff)
GetFileAttr (PathName, AttrArrayBuff)
Arguments
PathName

Write the full path of the folder or file for which you want to acquire attributes. Specify a character string or a variable that stores this value.

AttrArrayBuff

Specify the name of a dynamic one-dimensional array variable for storing the acquired attributes. The stored values may be any of the following:

Value

Meaning

ATTR_READONLY

Read-only file

ATTR_HIDDEN

Hidden file

ATTR_ARCHIVE

Archive file

ATTR_SUBDIR

Sub-directory

ATTR_SYSTEM

System file

ATTR_TEMPORARY

Temporary file

ATTR_COMPRESSED

Compressed file

ATTR_NORMAL

No particular attributes

The number of elements in the array variable are adjusted to the number of stored attributes.

Description

The GetFileAttribute or GetFileAttr command acquires the attributes set for the specified folder or file. The command returns True on successful execution, or False if an error occurs.

To set folder or file attributes, use the SetFileAttribute command. To check one attribute of a folder or file, use the IsFileAttribute command.

Note

Take care when specifying the folder, or a folder or file in the folder set in the following environment variables: ProgramFiles (normally the Program Files folder on the system drive) and WinDir (normally the Windows folder on the system drive). For details, see 1.8.2 Command behavior.

Example
' Delete all temporary files in the execution folder.
Dim file_attr()
For file = _SCF_+"*.*" Do
  ' Get file attributes.
  GetFileAttribute (file, file_attr)
  aryCnt = GetArrayCount (file_attr)
  ' Find temporary file attributes in the array variable
  ' that stores the file attributes.
    For  i = 1 To aryCnt
      If file_attr(i) = ATTR_TEMPORARY Then
        ' Delete the file.
        DeleteFile (file, ExclDir)
        Exit For
      End If
    Next
End For
JP1/Script version

Supported from JP1/Script 06-00.