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

is specified

 
 

Return type: Switch
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 string first,
     value string 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 ] [ LEGACY LIBRARIES ] [ ERRORS ]

OmniMark 8.2.0 Documentation Generated: March 13, 2008 at 3:33:48 pm
If you have any comments about this section of the documentation, please use this form.

Copyright © Stilo International plc, 1988-2008.