swirl
Guide to OmniMark 8   OmniMark home
docs home 
IndexConceptsTasksSyntaxLibrariesLegacy LibrariesErrors
 
  Related Syntax    
action  

assert

 
 

Syntax

assert test-expression (message string-expression)?


Purpose

You can use assert to verify any assumptions you are making at any given point in your code. To test an assumption, insert the word assert at an appropriate point in your code and follow it with a test expression that tests your assumption. If the test condition returns true, your program continues. If the test expression returns false, OmniMark throws a #program-error (error code 6133). You can specify an error message to accompany the error by adding a message parameter:

  global integer number-of-guesses initial {10}
  
  process
     assert number-of-guesses > 0 
      message "Illegal value for number-of-guesses"
     output "You have "
         || "d" % number-of-guesses
         || " guesses"

In this program the number of guesses is a global variable and is configurable on the command line. The assert statement tests to make sure that it is not set to a value that does not make sense.

    Related Syntax
   not-reached
 
 
 

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.