Usina BRAdvPL Guide
Sign in
← All topics
FUNCTIONUnder review

IndexKey

IndexKey([nOrdem]) -> cExpr

Obtains an index key expression.

IndexKeyAdvPL
01 · OVERVIEW

Overview

Zero or omitted nOrder reads the current index; missing index order returns an empty string. An unopened area can raise Work area not in use. The returned expression describes the key rather than its value in the record. (Sources: refs. 1–1.) The community positioning example also illustrates GetArea/RestArea and explicit index selection; it does not determine the order in every environment.

02 · SYNTAX

Syntax

IndexKey([nOrdem]) -> cExpr

Parameters

nOrdem
NumericOptional

Order; zero or omitted means current.

Return value

Key expression or empty string.

03 · PRACTICAL EXAMPLE

Commented example

#Include "Protheus.ch"

User Function Ed486()
    // Read only, without creating or changing indexes.
    If !Empty(Alias())
        ConOut(cValToChar(IndexKey(0)))
    EndIf
Return Nil
Expected result

Displays current-area metadata when an area is open. Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

BEST PRACTICES
  • Do not macro-execute untrusted expression text. Check the effective order before DbSeek.
  • Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

Related content

REFERENCES
  1. TOTVS. IndexKey. TDN. Accessed on 2026-10-27.
  2. Daniel Atilio. zIndPos.prw; commit 7d275a7. 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