Usina BRAdvPL Guide
Sign in
← All topics
FUNCTIONUnder review

PERTENCE()

Pertence(cExpressao) -> lOk

Validates current content against allowed options.

PERTENCE()AdvPL
01 · OVERVIEW

Overview

Takes an expression of allowed values and reads the current editing variable/field. Documentation uses MSGET VALID; it is not generic array search. This adaptation uses one character and options 0–4, avoiding undocumented separator semantics for multi-character identifiers. (Sources: refs. 1–1.)

02 · SYNTAX

Syntax

Pertence(cExpressao) -> lOk

Parameters

cExpressao
CharacterRequired

Expression containing allowed options.

Return value

Logical: current content occurs in the expression.

03 · PRACTICAL EXAMPLE

Commented example

#Include "Protheus.ch"

User Function Ed571()
    Local oDlg
    Local cValue := "0"
    // Validate current content, not an external array.
    DEFINE MSDIALOG oDlg TITLE "Example" FROM 0,0 TO 100,300 PIXEL
    @ 12,12 MSGET cValue SIZE 40,12 OF oDlg PIXEL VALID Pertence("01234")
    ACTIVATE MSDIALOG oDlg CENTERED
Return Nil
Expected result

The field accepts documented options 0–4 during validation; writes no data. Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

BEST PRACTICES
  • Test empty/out-of-list values; use suitable exact-list validation for multi-character keys. Verify editing context and do not assume a database lookup.
  • Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

Related content

REFERENCES
  1. TOTVS. PERTENCE%28%29. TDN. 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