FUNCTIONS CORE

IsNegative()

Test whether an answer means "no"

Syntax

Signature
IsNegative( cAnswer ) --> lIsNo

Arguments

cAnswer

The answer of the user, for example a key or a word.

Return value

.T. when the answer starts with the letter of "no" of NationMsg( 12 ), "N", in upper or lower case.

Description

IsNegative() is the counterpart of IsAffirm(). An answer that is neither "yes" nor "no" gives .F. in both.

Example

IsNegative.prg
PROCEDURE Main()

   Check( 'IsNegative( "No" )               ', IsNegative( "No" ), .T. )
   Check( 'IsNegative( "n" )                ', IsNegative( "n" ), .T. )
   Check( 'IsNegative( "y" )                ', IsNegative( "y" ), .F. )
   Check( '"x" is neither yes nor no        ', IsNegative( "x" ) .OR. IsAffirm( "x" ), .F. )

RETURN

STATIC PROCEDURE Check( cTitle, xResult, xExpected )

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

RETURN

Output

IsNegative( "No" )               OK
IsNegative( "n" )                OK
IsNegative( "y" )                OK
"x" is neither yes nor no        OK

See also