Usina BRAdvPL Guide
Sign in
← All topics
FUNCTIONUnder review

Left

Left(cText,nCount) -> cPrefix

Extracts a string prefix.

LeftAdvPL
01 · OVERVIEW

Overview

nCount defines how many positions to copy from the left. If it exceeds length, the full string is returned; zero or negative returns empty. The example uses ASCII to avoid assuming Unicode-character counting in the environment encoding. (Sources: refs. 1–1.)

02 · SYNTAX

Syntax

Left(cText,nCount) -> cPrefix

Parameters

cText
CharacterRequired

Input text.

nCount
NumericRequired

Number of positions.

Return value

Prefix string or empty string.

03 · PRACTICAL EXAMPLE

Commented example

#Include "Protheus.ch"

User Function Ed505()
    // Explicit extraction bounds.
    ConOut(Left("ED0102",4))
    ConOut("["+Left("ED01",0)+"]")
Return Nil
Expected result

Displays ED01 and []. Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

BEST PRACTICES
  • Validate type and length before using a prefix as a key.
  • Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

Related content

REFERENCES
  1. TOTVS. Left. TDN. Accessed on 2026-10-27.
Status
Under review
Page created on
Last reviewed on
Original language
Portuguese
Reviewed by
Usina.BR
0 approved comment(s)

Comments

There are no approved comments yet.

Sign in with Google or Microsoft to comment.

Powered by Usina Docs · Alpha