FUNCTIONS CORE

IsAffirm()

Test whether an answer means "yes"

Syntax

Signature
IsAffirm( cAnswer ) --> lIsYes

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 "yes" of NationMsg( 12 ), "Y", in upper or lower case.

Description

IsAffirm() reads the "yes" letter from the national messages, so a program asks with NationMsg( 12 ) and tests the answer without writing "Y" itself.

Example

IsAffirm.prg
PROCEDURE Main()

   Check( 'IsAffirm( "y" )                  ', IsAffirm( "y" ), .T. )
   Check( 'IsAffirm( "Yes" )                ', IsAffirm( "Yes" ), .T. )
   Check( 'IsAffirm( "n" )                  ', IsAffirm( "n" ), .F. )
   Check( 'IsAffirm( "" )                   ', IsAffirm( "" ), .F. )

RETURN

STATIC PROCEDURE Check( cTitle, xResult, xExpected )

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

RETURN

Output

IsAffirm( "y" )                  OK
IsAffirm( "Yes" )                OK
IsAffirm( "n" )                  OK
IsAffirm( "" )                   OK

See also