Using the Bar Operator

As of version 8 of TEM, you can use the bar ( | ) operator to iterate through a list and find the first item that doesn't produce an error. In the following example, we assume that the file gone.txt doesn't exist, so getting its size throws an error:

Q: size of file "c:\gone.txt" | 10
A: 10

The expression skips past the file error and lands on 10.

Q: (size of file "c:\gone.txt" > 0) | false
A: False

The bar operator is looking for errors, not true or false, so it will report false if that is the first error-free phrase.

Q: ( (not exists file "c:\gone.txt") | (size of file "c:\gone.txt" = 0) )
A: False

Because the bar operator can skip through errors, it can simplify your code. Typically you check for the existence of each file before examining it:

(
  if
   (
    exists result (it,bes properties "Shared Groups")
    whose (exists value of it)
   )
  then
   value of result (it,bes properties "Shared Groups")
  else
   "No Result"
 )
 of bes computers

Here is how you might write this using the bar operator:

(
  value of result (it,bes property "Shared Groups") | "No Result"
 )
 of bes computers

The bar operator just keeps iterating through the list until it reaches an error-free phrase, which in this case is the "No Result" message.