Usina BRAdvPL Guide
Sign in
← All topics
FUNCTIONUnder review

StrTokArr

StrTokArr(cText,cToken) -> aParts

Splits a string into array elements.

StrTokArrAdvPL
01 · OVERVIEW

Overview

Each cToken character acts independently as a delimiter. Thus "::" does not establish an indivisible sequence; check StrTokArr2 for composite delimiters. The source also documents stopping at the first ASCII 0. The example avoids empty fields and uses one delimiter, without inferring CSV quoting or escaping. (Sources: refs. 1–2.)

02 · SYNTAX

Syntax

StrTokArr(cText,cToken) -> aParts

Parameters

cText
CharacterRequired

Source text.

cToken
CharacterRequired

Delimiter characters.

Return value

Array of parts.

03 · PRACTICAL EXAMPLE

Commented example

#Include "Protheus.ch"

User Function Ed676()
    Local aParts := StrTokArr("A;B;C",";")
    // One position per token in this example without empty fields.
    ConOut(Len(aParts))
    ConOut(aParts[2])
Return Nil
Expected result

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

BEST PRACTICES
  • Test empty tokens, repeated delimiters and NUL input on the target build.
  • Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

Related content

REFERENCES
  1. TOTVS. StrTokArr. Sintaxe e observações. TDN. Accessed on 2026-10-28.
  2. Atilio. dan-atilio/AdvPL. Maratona de Exemplos/Exemplo_435_Funcoes_Separa_StrTokArr_e_StrTokArr2.prw. Arquivo completo consultado; adaptação editorial. Accessed on 2026-10-28.
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