has name

operator

Return type:
Switch
Returns:
Returns true if the specified stream item has a name, and false otherwise. Replacing has with hasnt will return the opposite results.
Syntax
stream-name indexer? (has | hasnt) name
    


Purpose

stream shelf items that are attached to files, referents and external functions have names. Also, the built-in stream #markup-parser can have the name XML or SGML.

If a stream shelf item has a name, the name of operator can be applied it to return a string expression containing its name.

The built-in stream #main-output has a name when it has been attached to a file on the command line that has -of or -aof options.

This example illustrates the use of has name to test whether a specified stream shelf item has a name. This is done in order to avoid the error of using the name of test on a stream that does not have a name.

  global stream new-output
  
  process
     do when new-output has name
       do unless name of new-output = "new-out.txt"
         put #error "stream new-output has unexpected name: "
         put #error name of new-output
         halt with 1
       done
  
     else
       put #error "new-output was never opened as file or referent%n"
       halt with 1
     done