Usina BRAdvPL Guide
Sign in
← All topics
FUNCTIONUnder review

AFill

AFill( <aDest>, <xValue>, [nStart], [nCount] ) --> aRet

Fills a range with one value.

AFillAdvPL
01 · OVERVIEW

Overview

AFill modifies existing elements and does not size the array. Without explicit bounds it fills from position 1 through the end. Any value type is accepted, but array or object values do not establish independent copies per slot. Prefer scalar initialization when it fits the data model. (TOTVS, s.d., ref. 1)

02 · SYNTAX

Syntax

AFill( <aDest>, <xValue>, [nStart], [nCount] ) --> aRet

Parameters

aDest
ArrayRequired

Sized array.

xValue
AnyRequired

Fill value.

nStart
NumericOptional

First position; default 1.

nCount
NumericOptional

Count from the starting position; defaults through the end.

Return value

Array after filling.

03 · PRACTICAL EXAMPLE

Commented example

#Include "Protheus.ch"

User Function EdAfill()
    Local aValues := Array(4)
    // Size first; fill only the required range.
    AFill(aValues, 0)
    AFill(aValues, 9, 2, 2)
    ConOut(cValToChar(aValues[1]))
    ConOut(cValToChar(aValues[2]))
Return Nil
Expected result

Expected array: {0, 9, 9, 0}; outputs 0 and 9. Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

BEST PRACTICES
  • Do not accidentally replace nested arrays with a scalar. Check bounds when ranges come from configuration.
  • Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

Related content

REFERENCES
  1. TOTVS. AFill. TDN. Accessed on 2026-10-25.
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