swirl Guide to OmniMark 5   OmniMark home
docs home 
IndexConceptsTasksSyntaxLibrariesOMX VariablesErrors
 
  Related Syntax   Related Concepts  
control structure   when, unless    

Syntax

  action|rule when condition
  action|rule unless condition

Where:
action


rule
condition

Purpose

You can usewhen and unless to make any OmniMark rule or action conditional. The rule will not fire, the action will not be executed, if the condition following when is false, or the condition following unless is true.

The following rule will fire when "hello" occurs in the data only if "count" is greater than 12:

  find "hello" when count > 12

The following action will be executed unless the variable "name" contains the string "Fred":

  output name unless name = "Fred"

when and unless can also be used to make any block or looping structure conditional by placing them at the end of the structure:

  do xml-parse document scan my-document
     output"%c"
  done unless my-flag

This is not particulary readable, however. It will usually be preferable to wrap the structure you want to make conditional in a do when or do unless block:

  do unless my-flag
     do xml-parse document scan my-document
        output "%c"
     done
  done

Note that do when and do unless are separate conditional structures, not do blocks with when or unless attached. do when and do unless allow for the use of else and else when within the block.

    Related Syntax
   do when, do unless
   true, false
 
Related Concepts
   Conditional constructs
 
----

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

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

Copyright © OmniMark Technologies Corporation, 1988-2000.