Usina BRAdvPL Guide
Sign in
← All topics
FOUNDATIONUnder review

NIL values and variable initialization

Distinguishes missing values from zero and empty strings.

NIL values and variable initializationAdvPL
01 · OVERVIEW

Overview

Nil has ValType U; zero is N, empty string C and .F. L. Initialization should match the intended contract rather than replacing absence with apparent success. Check content/ranges after type validation. The example uses declared xValue initialized with Nil, not an unknown variable name. This distinguishes undefined value from an unresolved-name error. (Sources: refs. 1–1.)

03 · PRACTICAL EXAMPLE

Commented example

#Include "Protheus.ch"

User Function Ed705()
    Local xValue := Nil
    // U differs from zero, empty text and false.
    ConOut(ValType(xValue))
    xValue := 0
    ConOut(ValType(xValue))
Return Nil
Expected result

Displays U and N. Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

BEST PRACTICES
  • Do not index arrays or access methods before validating result existence/shape.
  • Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

Related content

REFERENCES
  1. TOTVS. ValType. Tipos e Nil. 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