swirl Guide to OmniMark 5   OmniMark home
docs home 
IndexConceptsTasksSyntaxLibrariesOMX VariablesErrors
 
    Related Concepts  
operator   has key    

Return type: Boolean
Returns:       

Returns true if the shelf contains a key with the given name, and false otherwise. Replacing has with hasnt will reverse the results.



Syntax
  shelf test:
      shelf-name (has | hasnt) key string-expression
  attribute shelf test:
     specified? attribute (has | hasnt)  key string-expression
  or
  specified? data-attributes (has | hasnt) key string-expression


Purpose

has key is a test that determines if a shelf contains a key with the given string-expression.

hasnt key returns the opposite results.

has key can also be applied to an attribute shelf in a similar fashion.

The has key test can also determine whether an element has an attribute declared for it. It can be used on both the data-attributes and attributes shelves.

For example, the following code shows how has key can be used to test for a declared attribute:

  global stream id-name
  ...
  output attributes key id-name
     when attributes has key id-name and
        attribute key id-name isnt implied

In this example, the has key test is used to determine whether the switch shelf "assoc-list" currently contains an item with the name referred to by "%x(curr-key)".

  global switch assoc-list variable initial {true, false, true}
  global integer item-no
  process
     set key of assoc-list[1] to "black"
     set key of assoc-list[2] to "gold"
     set key of assoc-list[3] to "red"
     submit "{gold}foo-stuff for report"
     find "{" [ \ "}"]+ => curr-key "}"
        do when assoc-list has key "%x(curr-key)"
           set item-no to item of assoc-list{"%x(curr-key)"}
        else
        ; An index of 0 means that the key wasn't found.
           set item-no to 0
        done
     output "item-no = "
         || "d" % item-no
         || "%n"
  ; Output: "item-no = 2
  ;          foo-stuff for report"

      Related Concepts
   Attributes: list-valued
   Shelves
 
----  

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

Generated: August 11, 2000 at 3:07:19 pm
If you have any comments about this section of the documentation, send email to docerrors@omnimark.com

Copyright © OmniMark Technologies Corporation, 1988-2000.