Expressions

Use

Expressions are used in the file selection utility to calculate sets of files based on previously calculated sets along with attributes of the files. Expressions are used in two different ways.

The first use of an expression is to create automatic select lists. These select lists represent a set of files which is always up to date. The files contained in an automatic select list is determined by evaluating the expression which was used as the description of the select list when it was created. This evaluation occurs whenever an action within the file selection utilty could possibly have changed the set of files belonging to the select list.

The second use of an expression is as an argument to commands entered at the bottom of the main window of the file selection utility. Commands such as select and set require an expression used to determine the set of files used for the commands. Expressions used in commands are evaluated when the command is executed.

Syntax and Semantics

Expressions used in the file selection utility are very similar to expressions used in other applications. There are numeric constants, string constants, functions. There are operators such as addition, subtraction, multiplication, division, and modulo. There are comparison operators such as equality, less than, and so on. The syntax is very similar to a C-like expression.

The major difference in the expressions used in the file selection utility is that boolean expressions are used to generate sets of files. This is done by evaluating the expression one for each file in the file table, and if the boolean value is true then the file is added to a set. When the boolean expression has been evaluated for every file, then the resulting set of files is represents the result of the expression.

As an example of a boolean expression, the value of fileLength() > 1000 represents the set of files in the file table whose length is greater than 1000. This occurs because the greater than operator accepts two numeric values and returns a boolean result. Because the result is a boolean, the expression is evaluated for every file, and the fileLength function returns the appropriate file length for each file being tested.

All select list names are primitive binary values in expressions, and so represent the set of files which they contain. They can be used to generate other sets of files. For example, the expression !isDirectory is the set of all non-directory files since isDirectory is the name of a the select list which contains the set of directories, and ! is the NOT operator.

Currently, the final result of any expression must always be a boolean since the expressions are used for automatic select lists or command lines, both of which need a result which is a set of files. So an expression such as 3 + 4 is not acceptable and would generate an error, whereas 3 < 4 is legal (but silly since it is always true and results in the set of all files).