swirl
Guide to OmniMark 7   OmniMark home
docs home 
IndexConceptsTasksSyntaxLibrariesLegacy LibrariesErrors
 
  Related Syntax   Related Concepts  
operator  

is specified

 

 

Return type: Boolean
Returns:       

Returns true if the variable is specified and false otherwise. Replacing is with isnt will reverse the results.



Syntax
  argument-name (is | isnt) specified


Purpose

Used to test if the value of a variable or attribute has been specified. It has two applications: pattern variables and optional arguments of functions.

You can test a pattern variable to see if any value was assigned to it. Note that there is a difference between having no value assigned and having a value of empty string ("") assigned. A pattern variable is only unspecified if it is inside a pattern that is matched zero times. If it is assigned the value of a whole pattern that is matched zero times, it has the value of empty string (""). Thus this program:

  process
     submit "aaaaaazzzzzz"

  find "a"+ ("b" => found-1)? => found-2 "z"+
     output "found-1 is unspecified%n" when found-1 isnt specified
     output "found-2 is empty string%n" when found-2 = ""
will output:
  found-1 is unspecified
  found-2 is empty string

If you write a function that has optional arguments, you should test to make sure that the optional argument was specified in the function call before you attempt to use the argument:

  define function foo (
     value stream first,
     value stream second optional) as

     output first
     output second when second is specified

  process
     foo("one%n")
     foo("two%n", "three%n")

If you supplied a default value for the argument, you can use it safely even if it is not specified. The is specified test will still return false for an unspecified argument even if you give it a default value.

The is specified test is not permitted on a remainder argument.

    Related Syntax
   optional
   remainder
   attribute is specified
 
Related Concepts
   Attribute tests on items of the "attributes" shelf
   Attributes: type tests
 
 

Top [ INDEX ] [ CONCEPTS ] [ TASKS ] [ SYNTAX ] [ LIBRARIES ] [ LEGACYLIBRARIES ] [ ERRORS ]

OmniMark 7.1.2 Documentation Generated: June 28, 2005 at 5:45:22 pm
If you have any comments about this section of the documentation, send email to [email protected]

Copyright © Stilo Corporation, 1988-2005.