Usina BRAdvPL Guide
Sign in
← All topics
FUNCTIONUnder review

Replicate

Replicate(cString,nCount) -> cRet

Repeats a string a specified number of times.

ReplicateAdvPL
01 · OVERVIEW

Overview

Concatenates copies of the input; zero repetitions produce an empty string. The TDN page has historical coverage and states a 65,535-character limit for that contract; do not generalize it to every current build and setting. Bound requested sizes before repeating external data. The GitHub example uses TamSX3 for field padding; this adaptation is memory-only. (Sources: refs. 1–2.)

02 · SYNTAX

Syntax

Replicate(cString,nCount) -> cRet

Parameters

cString
CharacterRequired

String to repeat.

nCount
NumericRequired

Repetition count.

Return value

Character: concatenated copies.

03 · PRACTICAL EXAMPLE

Commented example

#Include "Protheus.ch"

User Function Ed617()
    // Memory-only operation; input remains unchanged.
    ConOut(Replicate("ab",3))
Return Nil
Expected result

Expected result: ababab. Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

BEST PRACTICES
  • Check types, bounds and context before using external input.
  • Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

Related content

REFERENCES
  1. TOTVS. Replicate. TDN. Accessed on 2026-10-27.
  2. Atilio. dan-atilio/AdvPL. Maratona de Exemplos/Exemplo_411_Funcao_Replicate.prw. Arquivo completo consultado; adaptação editorial. 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