Exists is an important keyword that returns TRUE or FALSE based upon the existence of the specified object. This is an important technique that lets you test for existence before you test for a value and possibly incur an error. The keyword has two slightly different typical uses. The first is to determine whether a singular object specified by an Inspector exists:

Q: exists drive "c:"
A: True
Q: exists drive "z:"
A: False

The above examples test for the existence of the specified objects on the client computer. In these examples, you can see that the client has a drive c:, but not a drive z:. Attempting to find out more about the non-existent drive can generate an error. If you aren’t sure about the existence of an object, use the ‘exist’ keyword before you attempt to examine its properties.

The second usage is to determine whether a plural result contains any values:

Q: exists (files of folder "c:")
A: True

This expression returns TRUE, since files exist on drive c:. Note that using the plural property (files) is a safe way to refer to something that may or may not exist. For instance:

Q: file of folders "z:"
E: Singular expression refers to nonexistent object.

An error is generated here because there is no drive "z:" on the client computer. If you ask for a plural answer,

Q: files of folders "z:"
I: plural file

It doesn’t give you an answer (there is no a: response), but it also doesn’t throw an error. Nevertheless, both of these constructs can be examined with the ‘exists’ keyword without causing an error:

Q: exists file of folders "z:"
A: False
Q: exists files of folders "z:"
A: False