Usina BRAdvPL Guide
Sign in
← All topics
FUNCTIONUnder review

SortArray / ScanArray

SortArray(aArray,[nStart],[nCount],[lAscending],nColumn); ScanArray(aArray,xValue,[nStart],[nCount],nColumn)

Sorts and searches arrays in historical eAdvPL.

SortArray / ScanArrayAdvPL
01 · OVERVIEW

Overview

SortArray receives range, Boolean direction and column; ScanArray receives expression, range and column and documents a position or zero. The guide has errors: SortArray return repeats search text, while aSize syntax prints ScanArray. We therefore assign no SortArray return or undocumented comparison semantics. The uninvoked block only demonstrates ScanArray with an explicit column. Check ASort and AScan separately for current AdvPL. (Sources: refs. 1–1.)

02 · SYNTAX

Syntax

SortArray(aArray,[nStart],[nCount],[lAscending],nColumn); ScanArray(aArray,xValue,[nStart],[nCount],nColumn)

Return value

ScanArray: position or zero; source SortArray return is inconsistent.

03 · PRACTICAL EXAMPLE

Commented example

#Include "Protheus.ch"

User Function Ed669()
    // eAdvPL reference; distinguish from current AScan.
    Local bSearch := {|aRows| ScanArray(aRows,"A",1,Len(aRows),1)}
    ConOut(ValType(bSearch))
Return Nil
Expected result

Creates block B; performs no sorting or searching during this execution. Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

BEST PRACTICES
  • Verify platform and handle zero before indexing. Test empty lists, partial ranges and row shapes.
  • Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

Related content

REFERENCES
  1. Guia de referência eAdvPL. §7.2–7.4. Inconsistências identificadas no texto histórico. 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