Usina BRAdvPL Guide
Sign in
← All topics
FUNCTIONUnder review

ValType

ValType( <xParam> ) --> cRet

Identifies the type of the supplied value.

ValTypeAdvPL
01 · OVERVIEW

Overview

ValType receives a value and returns a character code: A for array, B for code block, C for character, D for date, L for logical, N for numeric, O for object and U for undefined/Nil. The reference also lists F for fixed-point decimal; verify environment availability. Unlike Type, it does not receive an expression string. Type checking does not validate array length, contents or object properties. (Ref. 1)

02 · SYNTAX

Syntax

ValType( <xParam> ) --> cRet

Parameters

xParam
AnyRequired

Value whose type is to be identified.

Return value

Character identifying the value type.

03 · PRACTICAL EXAMPLE

Commented example

#Include "TOTVS.ch"

User Function EdTipo()
    Local uValue := Nil
    // Nil is a value stored in the variable, with code U.
    ConOut(ValType(uValue))
    uValue := {"A", "B"}
    If ValType(uValue) == "A"
        // The type does not establish the element count.
        ConOut(cValToChar(Len(uValue)))
    EndIf
Return Nil
Expected result

Expected results: U and 2. The variable exists from its declaration. Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

BEST PRACTICES
  • Do not evaluate missing identifiers to check their existence. Declare variables and validate required structure before indexing arrays.
  • Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

Related content

REFERENCES
  1. TOTVS. ValType. TOTVSTEC/TDN. Accessed on 2026-10-24.
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