do scan
Full Description
swirl
Syntax
  do scan string-expression
     (match pattern condition?
        local-declaration*
        action*)+
     (else
        local-declaration*
        action*)?
  done


Purpose

This scanning action specifies a number of match alternatives, each of which contains a sequence of actions to be performed if the value of the specified string expression matches the given pattern. The else phrase is optional. Only one else phrase may be used in a do scan action.

The actions in a match alternative are performed if the pattern matches all or part of the string expression. Each time a match alternative is tried, the pattern matching begins again at the beginning of the data to be scanned.

If a match alternative specifies a condition, then the condition must also be satisfied before the actions in that alternative will be executed.

A final sequence of actions can be preceded by the keyword else. Actions in the else condition will be performed if none of the other match alternatives are selected.

The following is a fairly standard do scan action that uses an else phrase. If the value of the "color" attribute is not black, gray, or blue, then the else phrase is selected:

  do scan "%v(color)"
    match ul "black"
      output "\background(black)"
    match ul "gray" | ul "grey"
      output "\background(gray)"
    match ul "blue" | ul "cyan"
      output "\background(cyan)"
    else
      output "\background(black)" ; default color
  done

Copyright © OmniMark Technologies Corporation, 1988-1998.