swirl
Guide to OmniMark 7   OmniMark home
docs home 
IndexConceptsTasksSyntaxLibrariesLegacy LibrariesErrors
 
     

Arithmetic and comparison operators

If you've got two or more values or variables and you want to do something with them or to them, you need an operator.

The most common sorts of operators are arithmetic operators, such as those which perform addition or multiplication. For example:

  process
     local integer x
     set x to 1 + 1
     output "%d(x)%n"

The arithmetic operators available in OmniMark are + (addition), - (subtraction), * (multiplication), / (division), and modulo (the remainder you get when you divide the number by the base value).

OmniMark also provides a full set of operators that are used to compare two or more numeric values. For example:

  process
     do when x = y
        output "equal%n"
     else when x > y
        output "greater%n"
     else when x < y
        output "lesser%n"
     done

The other available numeric comparison operators are != (not equal), >= (greater than or equal to), and <= (less than or equal to).

Other common operators are & and | (the and and or Boolean operators). These are usually used to create more complex conditions and tests in OmniMark. For example:

  process
     do when x = y & z > 4
        output "first test is true%n"
     else when y = z | x = 4
        output "second test is true%n"
     else
        output "neither test is true%n"
     done

Comparing records

You can compare two record variables using the reference identity operator, ==.

Overloading arithmetic and comparison operators

You can overload OmniMark's arithmetic and comparison operators to work with new data types, particularly types that you define using records, by writing overloaded functions. When you overload a comparison operator, the return type must be switch.

       
 

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

OmniMark 7.1.2 Documentation Generated: June 28, 2005 at 5:44:33 pm
If you have any comments about this section of the documentation, send email to [email protected]

Copyright © Stilo Corporation, 1988-2005.