Home

TOTVS Technology

Child pages
  • Strong Typing
Skip to end of metadata
Go to start of metadata

Scope
Version 17.3.0.0 and later

From version 17.3.0.0, the resource of strong typing is available for TL++. 
If the variable is typed and try to attribute a different value of the type, a compilation error will occur. 
If a function receives typed parameters and parameters passed do not correspond to the types specified, an execution error will occur. For functions that are declared and called in one source, a compilation error will occur. 
The types are the same ones available for ADVPL. 


Tipagem.tlpp
#include "protheus.ch"

static sVar1 as char
main Function tteci_181b()
  Local c1 as character
  Local n1 as numeric
  private pVar1 as logical
  n1 := 10
  c1 := "10"
  c1 := c1 + "10"
  sVar1 := '10'
  pVar1 := .t. 
Return


main Function tteci_181c()
  Local c1 as character
  Local l1 as logical
  c1 := "10"
  l1 := .T.
  ConOut("Chamada 1 - xTLog")
  ConOut(U_xTLogb(l1))
  ConOut("Chamada 2 - xTLog")
  /*ConOut(U_xTLogb(c1)) //C9902 argument #0 error, expected L found C, function U_XTLOGB*/
Return



User Function xTLogb(l2 as logical)
  If l2 = .T.
    ConOut("Logical .T.")
  Else
    ConOut("Logical .F.")
  EndIf
  l2 := .T.
Return l2




  • No labels