xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

Left()

Extracts characters from the left side of a string

Syntax

Left( <cString>, <nCount> ) --> cSubString

Arguments

<cString>
A character string to extract a substring from.
<nCount>
A numeric value specifying the number of characters to extract from the left side of <cString>.

Return

The function returns a character string containing Min( <nCount>, Len(<cString>) ) characters.

Description

The character function Left() extracts a substring from the left side of <cString>. The returned substring contains the first <nCount> characters. If <nCount> is larger than Len(<cString>), the return value is a copy of <cString>.

Left() is an abbreviated form of SubStr( <cString>, 1, <nCount>) and has a counterpart Right(), which extracts a substring from the right side of a string.

Info

See also:At(), HB_ATokens(), LTrim(), RAt(), Right(), RTrim(), Stuff(), SubStr()
Category: Character functions
Source:rtl\left.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example illustrates return values of function Left()

   PROCEDURE Main
      ? CDoW(Date())                   // result: Friday
      ? Left( CDoW(Date()), 3)         // result: Fri

      ? Time()                         // result: 14:45:12
      ? Left( Time(), 5)               // result: 14:45

      ? Left("xHarbour", 7)            // result: xHarbou
   RETURN

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