TOTVS Technology

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

Version and later

From version, 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. 

#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. 

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

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

  • No labels