Fórum Como buscar dados de outra unit? #190990
27/10/2003
0
Ex.
Variável texto1 da unit1 tem que ser igual a texto2 de unit2.
Michele
Curtir tópico
+ 0Posts
27/10/2003
Marcelo Saviski
unit Unit1; interface var texto1: string; implementation ...........
unit Unit2; interface var texto2: string; implementation ...........
unit Unit3; interface uses Unit1, unit2; function Compara: Boolean; implementation function Compara: Boolean; begin Result := Texto1 = Texto2; end; ...........
Pode fazer [color=green:68da86cd1d] Result := Unit1.Texto1 = Unit2.Texto2;[/color:68da86cd1d]
se preferir ou se ouver uma variavel com mesmo nome na Unit atual
Gostei + 0
27/10/2003
Michele
unit Unit2; interface var texto2: string; implementation Texto1:=10;
e não entendi o que é
Result := Texto1 = Texto2;
Gostei + 0
27/10/2003
Marcelo Saviski
é a mesma coisa que:
if Texto1 = Texto2 then
result := True
else
Result := False;
Result é o resultado da função, é o valor que vai ser passado quando vc chamar: Compara;
mas vc não precisa de uma função, pode colocar o código direto aonde vc irá trata-lo
ex; em um botão:
if Texto1 = texto2 then showMessage(´são iguais´) else ShowMessage(´são diferentes´);
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)