AdvPL
operators
Symbols and words that perform calculations, comparisons, assignments and special operations in AdvPL expressions.
01Mathematical
Perform numerical calculations.
Mathematical
Perform numerical calculations.
** or ^Exponentiation.
*Multiplication.
/Division.
%Modulo: remainder of division.
+Addition or positive sign.
-Subtraction or negative sign.
Local nPotencia := 2 ^ 3 // 8
Local nProduto := 6 * 4 // 24
Local nResto := 10 % 3 // 102Relational
Compare values and return a logical result.
Relational
Compare values and return a logical result.
<Less than.
>Greater than.
=Simple equality; for strings, it may consider a partial match.
==Exact equality, especially important for strings.
<=Less than or equal to.
>=Greater than or equal to.
<> or !=Not equal.
#Not equal, retained for compatibility; obsolete.
Local cCodigo := "ABC"
If cCodigo == "ABC"
ConOut("Código exato")
EndIf03Logical
Combine or invert logical expressions.
Logical
Combine or invert logical expressions.
.Not. or !Logical negation.
.And.Logical AND: all conditions must be true.
.Or.Logical OR: at least one condition must be true.
Local lAtivo := .T.
Local nSaldo := 100
If lAtivo .And. nSaldo > 0
ConOut("Disponível")
EndIf04Assignment
Store or update variable values.
Assignment
Store or update variable values.
:=Assigns a value.
+=Adds and assigns.
-=Subtracts and assigns.
*=Multiplies and assigns.
/=Divides and assigns.
^= or **=Raises to a power and assigns.
%=Calculates modulo and assigns.
Local nTotal := 10
nTotal += 5 // 15
nTotal *= 2 // 30
nTotal %= 7 // 205Increment and decrement
Change the value by one; position determines the value returned by the expression.
Increment and decrement
Change the value by one; position determines the value returned by the expression.
++xIncrements before returning the value.
x++Returns the current value, then increments.
--xDecrements before returning the value.
x--Returns the current value, then decrements.
Local nX := 5
Local nAntes := ++nX // nX=6, nAntes=6
Local nDepois := nX++ // nDepois=6, nX=706Strings
Concatenate or search character content.
Strings
Concatenate or search character content.
x + yConcatenates x and y.
x - yConcatenates and moves trailing spaces from x to the end of the result.
x $ yReturns true when x is contained in y.
Local cNome := "Usina" + ".BR"
Local lTem := "AdvPL" $ "Guia AdvPL"
ConOut(cNome) // Usina.BR
ConOut(lTem) // .T.07Special
Operate on code, structures, references, aliases and objects.
Special
Operate on code, structures, references, aliases and objects.
&cVariavelOperador macro: avalia o conteúdo como expressão AdvPL.
| |Delimita a lista de argumentos de um bloco de código.
( )Chamada de função or agrupamento de expressão.
[ ]Acesso a elemento de matriz.
{ }Bloco de código or valores literais de matriz.
->Acesso a campo por alias.
@Passagem de parâmetro por referência.
;Continuação or separação de instruções, conforme o contexto.
:Envio de mensagem, acesso a método or membro de objeto.
Local aDados := {"A", "B"}
Local bExibe := {|cTexto| ConOut(cTexto)}
Local cCampo := "A1_NOME"
Eval(bExibe, aDados[1])
ConOut(SA1->&cCampo)- Programação em ADVPL. Microsiga, 10 ago. 2007, p. 6-7. Content reorganized with examples added.
- TOTVS. Operadores Comuns. TDN. Additional technical reference.
- TOTVS. Microsiga Protheus SDK. TDN — additional reference.
