Usina BRAdvPL Guide
Sign in
← All topics
COMMANDPublished

@ ... GET

@ <nRow>, <nCol> GET [<oGet> VAR] <uVar> [OF <oWnd>] [PICTURE <cPict>] [VALID <cbValid>] [WHEN <cbWhen>] [READONLY] [PASSWORD]

Creates a TGet field for editing character, numeric or date values in an AdvPL interface.

Visual interfaceGETTGetData inputValidationCommands
01 · OVERVIEW

Overview

The @ ... GET command creates an input control bound to a character, numeric or date AdvPL variable. During compilation it is translated into the TGet class New() constructor. Input may use a PICTURE mask, exit validation, an enablement condition and change events, as well as read-only and password modes.

02 · SYNTAX

Syntax

@ <nRow>, <nCol> GET [<oGet> VAR] <uVar> [OF <oWnd>] [PICTURE <cPict>] [VALID <cbValid>] [WHEN <cbWhen>] [READONLY] [PASSWORD]

Parameters

nRow, nCol
NuméricoRequired

Row and column where the field is placed. With PIXEL, coordinates start at the upper-left corner of the parent.

oGet VAR
ObjetoOptional

Variable receiving the TGet object. When supplied, VAR must precede the edited variable.

uVar
Caractere, numérico ou dataRequired

Character, numeric or date variable whose value is displayed and edited.

OF oWnd
ObjetoOptional

Dialog, panel, folder or other container that owns the GET. OF is recommended.

PICTURE cPict
CaractereOptional

Mask controlling value formatting and editing.

VALID cbValid
LógicoOptional

Validation run when focus is lost; it must return .T. to allow leaving.

WHEN cbWhen
LógicoOptional

Condition evaluated during focus changes to determine whether the field may receive focus.

ON CHANGE cbChange
EventoOptional

Action executed when the editable content changes.

READONLY
CláusulaOptional

Allows focus, selection and copying but prevents editing.

PASSWORD
CláusulaOptional

Visually hides typed characters with asterisks.

SIZE · FONT · COLOR · PIXEL
CláusulasOptional

Customize dimensions, font, colors and coordinate system.

03 · PRACTICAL EXAMPLE

Masked input with validation

#Include "TOTVS.ch"

User Function ExGetCustomer()
    Local oDlg
    Local oGetCode
    Local cCode := Space(6)

    Define Dialog oDlg Title "Customer identification" ;
        From 100, 100 To 260, 520 Pixel

    @ 18, 20 Say "Code:" Of oDlg Pixel
    @ 16, 65 Get oGetCode Var cCode ;
        Picture "@!" Size 90, 12 Of oDlg Pixel ;
        Valid !Empty(AllTrim(cCode))

    Activate Dialog oDlg Centered
Return
Expected result

PICTURE transforms input according to the mask and VALID prevents leaving while the code is empty.

04 · PRACTICAL EXAMPLE

Password and read-only fields

#Include "TOTVS.ch"

User Function ExGetAcesso()
    Local oDlg
    Local cUsuario := "OPERADOR"
    Local cSenha := Space(20)

    Define Dialog oDlg Title "Acesso" ;
        From 0, 0 To 220, 480 Pixel

    @ 15, 20 Say "Usuário:" Of oDlg Pixel
    @ 13, 70 Get cUsuario Size 100, 12 ;
        Of oDlg Pixel ReadOnly

    @ 45, 20 Say "Senha:" Of oDlg Pixel
    @ 43, 70 Get cSenha Size 100, 12 ;
        Of oDlg Pixel Password ;
        Valid !Empty(AllTrim(cSenha))

    Activate Dialog oDlg Centered
Return
Expected result

READONLY allows viewing and copying the user without changing it; PASSWORD visually masks the password during editing.

BEST PRACTICES
  • Include TOTVS.ch to make the command available to the compiler.
  • Initialize uVar with the correct type before creating the component.
  • Use a PICTURE compatible with the data type and expected format.
  • Use VALID for exit validation, WHEN for entry control and ON CHANGE for editing reactions.
  • Use oGet VAR only when properties or methods are needed after creation.
  • Prefer PIXEL, although GET also accepts PIXELS according to the documentation.
  • Prefer OF to explicitly identify the owner container.
COMMON PITFALLS
  • When an object is supplied, omitting VAR makes the declaration invalid.
  • VALID and WHEN must return logical values.
  • A PICTURE incompatible with the variable type may restrict or display the value incorrectly.
  • PASSWORD only masks the display; it does not replace secure storage, encryption or access controls.
  • ON CHANGE may run many times while typing; keep the action lightweight.
  • Without OF, the field is bound to the active window or dialog.

Related content

REFERENCES
  1. TOTVS. @ ... GET. TDN. Created by Julio Wittwer; last changed on May 29, 2019.
  2. TOTVS. TGet:New — constructor used by the command. TDN.
  3. TOTVS. AdvPL formatting and editing pictures. TDN.
  4. eADVPL Reference Guide. No author identified, created July 28, 2005. Related section: p. 13–14. Historical reference; syntax checked primarily against a current source.
Status
Published
Page created on
Last reviewed on
Original language
Portuguese
Reviewed by
Usina.BR