Usina BRAdvPL Guide
Sign in
← All topics
FUNCTIONUnder review

Stuff

Stuff( <cString>, <nPosInicial>, <nExcluir>, <cAdicao> )

Replaces part of a string starting at a given position.

StringsReplacementText
01 · OVERVIEW

Overview

Replaces part of a string starting at a given position. This page was created from the historical training material and structured for quick reference, with practical notes and cautious use in current Protheus environments.

02 · SYNTAX

Syntax

Stuff( <cString>, <nPosInicial>, <nExcluir>, <cAdicao> )

Parameters

cString
CharacterRequired

Parameter used by the function. Check the Portuguese source page for the detailed original wording while this entry remains under review.

nPosInicial
NumericRequired

Parameter used by the function. Check the Portuguese source page for the detailed original wording while this entry remains under review.

nExcluir
NumericRequired

Parameter used by the function. Check the Portuguese source page for the detailed original wording while this entry remains under review.

cAdicao
CharacterRequired

Parameter used by the function. Check the Portuguese source page for the detailed original wording while this entry remains under review.

03 · PRACTICAL EXAMPLE

Replacing a fragment

User Function ExStuff()
    Local cCode := "ABC000XYZ"

    cCode := Stuff(cCode, 4, 3, "123")
    MsgInfo(cCode)
Return
Expected result

The 000 fragment is replaced by 123.

BEST PRACTICES
  • Pode inserir texto sem remover nada quando nExcluir for zero.
  • Use SubStr() quando apenas precisar ler parte do texto.
COMMON PITFALLS
  • This entry is under review because it was structured from historical training material.
  • Confirm behavior in the Protheus/AppServer release used in your environment.

Related content

REFERENCES
  1. Programação em ADVPL Completo. Training material recorded in the official documentation, section 4.5.4, p. 45-50. Summarized, reviewed and examples adapted.
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