Usina BRAdvPL Guide
Sign in
← All topics
FOUNDATIONPublished

Visual components in AdvPL

DEFINE ... · @ ... SAY · @ ... GET · @ ... BUTTON · ACTIVATE ...

Understand how visual commands provide readable syntax for instantiating and configuring interface classes.

Visual interfaceComponentsCommandsClassesDialogs
01 · OVERVIEW

Overview

AdvPL visual component commands make interface classes available through simpler instructions. During compilation, these commands are translated into constructor and method calls on the corresponding classes. Keywords such as FROM, TO, SIZE, OF and ACTION make parameters easier to recognize and improve code readability and maintenance.

02 · SYNTAX

Syntax

DEFINE ... · @ ... SAY · @ ... GET · @ ... BUTTON · ACTIVATE ...
03 · PRACTICAL EXAMPLE

Simple dialog with SAY, GET and BUTTON

#Include "TOTVS.ch"

User Function ExVisual()
    Local oDlg
    Local cName := Space(40)

    Define MsDialog oDlg Title "Quick entry" ;
        From 0, 0 To 150, 360 Pixel

    @ 20, 20 Say "Name:" Size 40, 10 Of oDlg Pixel
    @ 18, 65 Get cName Size 110, 10 Of oDlg Pixel
    @ 50, 65 Button "Confirm" Size 55, 14 ;
        Action MsgInfo("Hello, " + AllTrim(cName)) Of oDlg Pixel

    Activate MsDialog oDlg Centered
Return
Expected result

The dialog is the container. SAY shows a label, GET edits the variable and BUTTON runs an action block.

04 · PRACTICAL EXAMPLE

Event forwarded to a function

#Include "TOTVS.ch"

User Function ExAcaoVisual()
    Local oDlg

    Define MsDialog oDlg Title "Processamento" ;
        From 0, 0 To 120, 300 Pixel

    @ 35, 85 Button "Executar" Size 55, 14 ;
        Action ProcessarPedido() Of oDlg Pixel

    Activate MsDialog oDlg Centered
Return

Static Function ProcessarPedido()
    MsgInfo("Processamento iniciado")
Return
Expected result

The ACTION block remains short and delegates the rule to a function, improving readability and testing.

05 · PRACTICAL EXAMPLE

Command and class responsibilities

// Forma declarativa por comando:
@ 20, 20 Say "Cliente:" Size 45, 10 Of oDlg Pixel

// Na compilação, o comando é convertido em chamadas
// da classe visual correspondente. A implementação
// exata depende do componente e da versão da LIB.
Expected result

Keyword syntax makes source intent clearer, while the class supplies the component’s actual behavior.

BEST PRACTICES
  • Command syntax is a compiler-provided layer; at runtime, behavior is performed by the corresponding visual classes.
  • Use OF to explicitly identify the dialog or container that owns the component.
  • Organize interface creation, configuration and activation in a clear order.
  • Code blocks are commonly used for ACTION, VALID, WHEN and other component events.
  • Consult the command or class documentation to confirm parameters, include files and availability in the LIB in use.
COMMON PITFALLS
  • Do not mix PIXEL coordinates with other units without checking the container’s expected convention.
  • A component without the correct dialog association may not appear or may have an unexpected lifecycle.
  • Large event blocks make maintenance and debugging harder; call a dedicated function instead.
  • Command/class equivalence does not mean every class option is necessarily exposed by command syntax.
  • Historical interfaces may depend on SmartClient and routine context; confirm compatibility with the environment and execution type.

Related content

REFERENCES
  1. TOTVS. Visual Components. TDN. Created by Julio Wittwer; last changed on May 27, 2019.
  2. eADVPL Reference Guide. No author identified, created July 28, 2005. Related section: p. 11–25. Historical reference; syntax checked primarily against a current source.
Status
Published
Page created on
Last reviewed on
Original language
Portuguese
Reviewed by
Usina.BR