xHarbour Reference Documentation > Operator Reference xHarbour Developers Network  

<=

Less than or equal operator (binary): compares the size of two values.

Syntax

<Expression1> <= <Expression2>

Arguments

<Expression1>
The values of <Expression1> and <Expression2> must have the same data type and are compared.

Description

The "less than or equal" operator compares two values of the same data type. It returns .T. (true) when the left operand is smaller than or equal to the right operand, otherwise the return value is .F. (false).

Only the simple data types Character, Data, Logic, Memo and Numeric can be compared. The complex data types Array, Code block, Hash, Object and the value NIL cannot be used with the "less than or equal" operator.

Comparison rules
Data typeComparison
CharacterThe comparison is based on the ASCII value of the characters.
DateThe comparison is based on the underlying date value.
LogicalFalse (.F.) is smaller than true (.T.).
MemoSame as Character data type.
NumericComparison is based on the value of the numerics.

SET EXACT

For character comparisons, the "less than or equal" operator takes the SET EXACT setting into account. With SET EXACT OFF, characters are compared up to the length of the right operand. With SET EXACT ON, characters are compared up to the length of the left operand and trailing blank spaces are ignored.

Info

See also:$, <, <> != #, = (comparison), ==, >, >=, SET EXACT
Category: Comparison operators , Operators
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example demonstrates the result of the "<=" operator.

   PROCEDURE Main
      ? "A" <= "Z"               // result: .T.
      ? "a" <= "Z"               // result: .F.

      ? CToD("12/28/2005") <= CToD("12/31/2005")
                                 // result: .T.
      ? .T. <= .F.               // result: .F.

      ? 2 <= 1                   // result: .F.

      SET EXACT OFF
      ? "a"  <= "a    "          // result: .T.
      ? "a " <= "a"              // result: .T.
      ? ""   <= "a"              // result: .T.
      ? "a"  <= ""               // result: .T.

      SET EXACT ON
      ? "a"  <= "a    "          // result: .T.
      ? "a " <= "a"              // result: .T.
      ? ""   <= "a"              // result: .T.
      ? "a"  <= ""               // result: .F.
   RETURN

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe