FAttribute Function

Action

Checks, sets, and removes attributes for the specified file.

If the file name includes a directory name, the file is opened in the specified directory. Otherwise, Silk Performer searches for the file in the directory where the test script is located, in the data directory, in the results directory, and in the project directory.

Include file

Kernel.bdh

Syntax

FAttribute( in sFileName   : string,
            in nAttributes : number,
            in nOperation  : number ): boolean;

Return value

  • true if the check operation was performed and the attribute was set or if the attribute was successfully added or removed.

  • false otherwise

Parameter Description
sFileName Name of the file
nAttributes

Attributes of the specified file. Any combination of the following flags is valid:

  • OPT_FILE_ATTRIB_ARCHIVE

  • OPT_FILE_ATTRIB_HIDDEN

  • OPT_FILE_ATTRIB_READONLY

  • OPT_FILE_ATTRIB_SYSTEM

nOperation

Specifies whether to check, set or remove attributes. Possible values are:

  • OPT_FILE_ATTRIB_GET

  • OPT_FILE_ATTRIB_ADD

  • OPT_FILE_ATTRIB_REMOVE

Example

dcltrans
  transaction TMain
  const
    scFileName := "c:\\temp\\dummyfile.txt";
  begin
    // check whether system file is hidden
    if FAttribute("c:\\io.sys",OPT_FILE_ATTRIB_HIDDEN, OPT_FILE_ATTRIB_GET) then
    write("hidden"); writeln;
    else
      write("visible"); writeln;
    end;

    // set read-only attribute for test file
    FAttribute(scFileName, OPT_FILE_ATTRIB_READONLY, OPT_FILE_ATTRIB_ADD);
    write("test file is now read-only"); writeln;
    // remove read-only attribute again
    FAttribute(scFileName, OPT_FILE_ATTRIB_READONLY, OPT_FILE_ATTRIB_REMOVE);
    write("read-only attribute removed"); writeln;
  end TMain;

Output

hidden
test file is now read-only
read-only attribute removed