Usina BRAdvPL Guide
Sign in
← Catalog
LANGUAGE AND LEARNING PATH

The AdvPL language

Understand what AdvPL is, how it fits into Protheus, and progress through organized lessons — from your first source file to more complete architectures.

View the complete learning path →
01

Start with the language

AdvPL — Advanced Protheus Language — is a language developed for the Protheus ecosystem. Its origins are connected to the xBase standard and the need to preserve and evolve business applications built by Microsiga.

The language supports procedural, object-oriented and event-driven programming. Sources are compiled into the application repository and executed by AppServer. In current development, Visual Studio Code with the TOTVS Developer Studio extension is one of the available tools.

02

What matters when learning a programming language?

Learning a language is more than memorizing syntax. It means understanding the problems it solves, the environment where it lives, how source code becomes execution and which ideas it can express. In AdvPL, these questions are closely tied to Protheus.

01

Purpose and domain

AdvPL was created to develop and customize business applications in the Protheus ecosystem. It is used for business rules, processing, data access, reports, interfaces, entry points and integrations. Learning AdvPL also means understanding Protheus architecture and contracts.

02

Programming paradigms

The language combines procedural, object-oriented and event-driven programming. A solution may be organized as functions, use classes and methods, or react to interface actions. The right paradigm depends on the framework, routine responsibility and environment version.

03

Syntax and source structure

Its xBase heritage appears in reserved words, expressions, commands and conventions. A source file may contain includes, user functions, variables, conditions, loops, calls and returns. Syntax is the form; what matters is how these elements express flow and business rules.

04

Data, types and scope

Characters, numbers, dates, logical values, arrays, code blocks and objects are common. AdvPL supports dynamic typing and type declarations. Local, Static, Private and Public scopes determine visibility and lifetime; understanding them prevents side effects and silent errors.

05

Compilation and execution

Source code is not run directly like a script. It is compiled with compatible includes, incorporated into the repository and executed by AppServer. Configuration, release, RPO, libraries and permissions are part of the path from writing to running code.

06

Language, library and framework

Not everything called by an AdvPL program belongs to the language core. There are language keywords and operators, platform functions, Framework classes and module APIs. Distinguishing these layers helps identify documentation, includes, dependencies and compatibility.

07

Integration with Protheus

Many routines operate on aliases, tables, dictionaries, parameters, transactions and Protheus sessions. Others build interfaces or consume services. Behavior may depend on context, company and branch, user, module and release.

08

Strengths, constraints and evolution

AdvPL provides deep ERP integration and historical continuity. Legacy code, dynamic scopes, version dependencies and specific APIs require discipline. Explicit declarations, work-area preservation, return validation, error handling and tests on the supported release are essential.

03

Continue in the training area

The official path now brings together 52 lessons, organized from foundation to advanced level, with progress, exercises, targeted reviews, and projects.

View the complete learning path →

04

Your first source file

A simple routine already shows important elements: an include, a user function, a local variable, a function call and a return.

Expected result

When the function is run in the appropriate environment, the user receives a message. The example uses an English variable name, following the page language.

#Include "TOTVS.ch"\n\nUser Function HelloAdvPL()\n    Local cMessage := "Hello, AdvPL!"\n\n    MsgInfo(cMessage, "First program")\nReturn
05

From source to execution

The source file is written and compiled against includes compatible with the environment. The result is stored in the repository and executed by AppServer. Resources, permissions, libraries and behavior depend on the Protheus version in use.

06

History without confusing the present

Sources record different milestones: Silva (2004, p. 11) places the beginning of the language evolution in 1994, while Stal (2010, p. 136) records 1999 as the ADVPL launch. These may represent different stages of the same process.

Read the historical article →
REFERENCES
  1. SILVA, Waterloo Ferreira da. A Linguagem AdvPL. 2004. p. 11.
  2. TOTVS. AdvPL. TDN. Accessed Aug. 8, 2026.
  3. TOTVS. TOTVS Developer Studio for VS Code. TDN.
  4. STAL, Eva. Internacionalização de empresas brasileiras e o papel da inovação na construção de vantagens competitivas. Revista de Administração e Inovação, v. 7, n. 3, p. 120–149, 2010.
  5. TOTVS. Microsiga Protheus SDK. TDN — additional reference.
Page created on
Last reviewed on
0 approved comment(s)

Comments

There are no approved comments yet.

Sign in with Google or Microsoft to comment.

Powered by Usina Docs · Alpha