Dúvidas com mais de uma Condição (if)
Vejamos a function abaixo (os valores e variáveis são fictícios. Só para melhor compreensão):
function Testando(VTeste, VTeste2, VTeste3, VTeste4 : Integer) : Integer;
begin
Rotina linha 1: if VTeste = 1 then if VTeste2 = 2
Rotina linha 2: if VTeste3 = 4 then
Rotina linha 3: if VTeste4 = 5 then
Rotina linha 4: Result := 10;
end;
O que eu preciso é que, na linha 1, se VTeste não for igual 1, não execute o segundo if (´if Vteste2 = 2´), mas continue a exceução da linhas seguintes (2, 3 e 4).
Só não executaria as linhas 2 em diante, se VTeste2 for diferente de 2.
Tentei assim: Rotina linha 1: ´(if VTeste = 1) and (VTeste2 = 2) then´, mas aí se VTeste for diferente de 1, as linhas 2 em diante não são executadas.
Como ficaria a rotina para fazer o que preciso?
Obrigado.
function Testando(VTeste, VTeste2, VTeste3, VTeste4 : Integer) : Integer;
begin
Rotina linha 1: if VTeste = 1 then if VTeste2 = 2
Rotina linha 2: if VTeste3 = 4 then
Rotina linha 3: if VTeste4 = 5 then
Rotina linha 4: Result := 10;
end;
O que eu preciso é que, na linha 1, se VTeste não for igual 1, não execute o segundo if (´if Vteste2 = 2´), mas continue a exceução da linhas seguintes (2, 3 e 4).
Só não executaria as linhas 2 em diante, se VTeste2 for diferente de 2.
Tentei assim: Rotina linha 1: ´(if VTeste = 1) and (VTeste2 = 2) then´, mas aí se VTeste for diferente de 1, as linhas 2 em diante não são executadas.
Como ficaria a rotina para fazer o que preciso?
Obrigado.
Armindo
Curtidas 0
Respostas
Armindo
15/09/2007
corrigindo: no final da primeira linha tem mais um ´then´
if VTeste = 1 then if VTeste2 = 2 then
if VTeste = 1 then if VTeste2 = 2 then
GOSTEI 0
Dbergkamps10
15/09/2007
tente assim:
Espero ter ajudado...
if Vteste = 1 then begin if VTeste = 2 then... end; if Vteste = 2 then ... if VTeste3 = 4 then if VTeste4 = 5 then Result := 10;
Espero ter ajudado...
GOSTEI 0