PC SOFT

GRUPOS DE DISCUSSÃO PROFISSIONAL
WINDEVWEBDEV e WINDEV Mobile

Inicio → WINDEV 25 → Wx - Trabalhando com Procedure Overload (Prototype overload/Overload)
Wx - Trabalhando com Procedure Overload (Prototype overload/Overload)
Iniciado por Boller, out., 29 2015 1:35 PM - Sem resposta
Membro registado
4.520 mensagems
Publicado em outubro, 29 2015 - 1:35 PM
Prezados,

As vezes é necessário que a procedure tenha comportamentos diferentes dependendo do tipo de dado de entrada ou quantidade de parametros diferentes.

Criando a Procedure Overload
// First syntax
Procedure p(s is string)
s = s + s
RESULT(s)

// Second syntax
Procedure p(n is int)
n = n + n + n
RESULT(n)

// Third syntax
Procedure p(n is int, s is string)
retorno is string = n + n + n +s + s
RESULT(retorno)

// Fourth syntax
Procedure p(s is string, n is int)
retorno is string = s +n
RESULT(retorno)


Usando a Procedure Overload
// Calls

// Calls the first syntax (best corresponding syntax)
valor1 is string = p("A")

// Calls the second syntax (best corresponding syntax)
valor2 is string = p(1)

// Calls the third syntax (best corresponding syntax)
valor3 is string = p(1,"A")

// Calls the fourth syntax (best corresponding syntax)
valor4 is string = p("A",1)

// Calls the third syntax
// (equivalent to the fourth one, the third one has priority because described before)
valor5 is string = p(1,1)

// Calls the third syntax
// (equivalent to the fourth one, the third one has priority because described before)
valor6 is string = p("A","A")


Link de referencia:
http://doc.windev.com/en-US/…

Faça os testes e veja o quanto melhora o seu codigo criando dentro da procedure a mesma procedure com entradas de paramentros diferentes e com result.

Se mesmo assim tiver duvida entre em contato comigo, terei o prazer em ajudar.

--
Adriano Jose Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 9949 1800
adrianoboller@gmail.com
skype: adrianoboller
______________________________________________