Manual Access

Sometimes it may be necessary for a macro to explicitly request access to a file outside the sandbox and persist that access for subsequent runs. The following commands aid the macro author in manually managing that task.

File.requireAccessAtPath path v2.1

If a macro has never requested access to the file with the given path, this command will ask the user to select the file in a standard Open dialog. This will grant macros access to the file and also learn the given file path for later. Any subsequent uses of this command with the same path will automatically restore access to the file without interrupting the user.

This command can also be used with a folder path. In this mode the macro is granted access to all files and folders within that folder, including all those in nested subfolders, no matter how many levels deep.

If access to the file was not restored or granted, stops the macro.

File.learnAccessAtPath path, [isRestorationAutomatic] v2.1

If a macro already has access to the file with the given path, this command will learn the path so access can be restored using either File.requireAccessAtPath or File.restoreAccessAtPath.

If the optional argument isRestorationAutomatic is true then access will be restored automatically for any future macro execution, across all macros, without the need to use explicit commands like File.requireAccessAtPath. If this argument is not given, the default is false (not automatic). This argument was added for v2.1.1.

Returns @true if access to the file was learned, or @false if the macro does not have such access.

NOTE: in most cases this command is superfluous.

If you want all your macros to automatically always have access to a particular file or folder, it is easier to just use the built-in macro Macro > Application > Manage Macro File Access to grant that access.

If a macro needs to explicitly manually file access, it is still easier to use File.requireAccessAtPath.

File.restoreAccessAtPath path v2.1

If the given file path was learned previously using either the File.requireAccessAtPath or File.learnAccessAtPath commands, restores that access.

Returns @true if access to the file was restored, or @false if the path had not previously been learned (or the file no longer exists).

NOTE: in most cases this command is superfluous. It is easier to use just File.requireAccessAtPath.

File.forgetAccessAtPath path v2.1

Removes access to the file path learned previously using either the File.requireAccessAtPath or File.learnAccessAtPath commands.

Returns @true if access to the file path was forgotten, or @false if the file path had not previously been learned.

File.learnedAccessiblePaths [onlyAutomatic] v2.1

Returns an array of all paths to which access had been previously been learned.

If the optional argument onlyAutomatic is true then this only returns files to which access will be restored automatically by Nisus Writer for all subsequent macro execution. If this argument is not given, the default is false (return all files). This argument was added for v2.1.1.

NOTE: Nisus Writer Pro comes with a macro to help the user manage learned file paths. It lists all file paths that have been learned and allows the user to rescind access to any of them. By default it is located on the menu:

Macro > Application > Manage Macro File Access


Previous Chapter
Automatic Access
<<  index  >>
 
Next Chapter
Document Manager