FUNCTIONS CT

NumOr()

Join numbers with a bitwise OR

Syntax

Signature
NumOr( nWord1 | cHexWord1, nWord2 | cHexWord2, [nWordN | cHexWordN, ...] ) --> nWordOr

Arguments

nWord1 | cHexWord1

, nWord2 | cHexWord2, ... Numbers, or the same numbers as strings of hex digits, for example "10".

Return value

All arguments joined with OR. -1 when an argument is invalid.

Description

A bit of the result is 1 when it is 1 in any argument. Use NumOr() to set some bits and keep the others.

Notes

An invalid argument gives -1 and raises no error.

Example

NumOr.prg
PROCEDURE Main()

   /* 00000011 OR 00010000 = 00010011 */
   Check( 'NumOr( 3, 16 )                   ', NumOr( 3, 16 ), 19 )
   Check( 'NumOr( 1, 2, "4" )               ', NumOr( 1, 2, "4" ), 7 )
   Check( 'NumOr( 3, .T. )                  ', NumOr( 3, .T. ), -1 )

RETURN

STATIC PROCEDURE Check( cTitle, xResult, xExpected )

   QOut( cTitle + IIF( xResult == xExpected, "OK", "ERROR" ) )

RETURN

Output

NumOr( 3, 16 )                   OK
NumOr( 1, 2, "4" )               OK
NumOr( 3, .T. )                  OK

See also