Usina BRAdvPL Guide
Sign in
← All topics
FUNCTIONUnder review

ADel

ADel( <aSource>, <nPos> ) --> aRet

Removes an element without reducing array length.

ADelAdvPL
01 · OVERVIEW

Overview

ADel shifts following elements backward and leaves Nil in the last position. Len stays unchanged. If the intent also removes the excess slot, use ASize after validating the position. Saved indexes for later elements may no longer identify the same items. (TOTVS, s.d., ref. 1)

02 · SYNTAX

Syntax

ADel( <aSource>, <nPos> ) --> aRet

Parameters

aSource
ArrayRequired

Array to modify.

nPos
NumericRequired

Valid position starting at 1.

Return value

Array resulting from removal.

03 · PRACTICAL EXAMPLE

Commented example

#Include "Protheus.ch"

User Function EdAdel()
    Local aItems := {"A", "B", "C"}
    Local nPos := 2
    If nPos >= 1 .And. nPos <= Len(aItems)
        // Shift first, then remove the excess final slot.
        ADel(aItems, nPos)
        ASize(aItems, Len(aItems) - 1)
    EndIf
    ConOut(aItems[2])
Return Nil
Expected result

Expected result: {"A", "C"}, output C. Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

BEST PRACTICES
  • When deleting multiple positions, traverse backward or recompute indexes. Do not shrink when removal did not occur.
  • Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

Related content

REFERENCES
  1. TOTVS. ADel. 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