Commetn déclarer des variables utilisables dans plusieurs unit ?

Résolu
chacarre Messages postés 9 Date d'inscription mardi 22 avril 2008 Statut Membre Dernière intervention 28 avril 2008 - 28 avril 2008 à 15:36
f0xi Messages postés 4205 Date d'inscription samedi 16 octobre 2004 Statut Modérateur Dernière intervention 12 mars 2022 - 28 avril 2008 à 19:32
Bonjour,
et oui encore moi !! ^^
Donc voilà, j'ai besoin de certaine variable dans plusieurs unit. Je pensais qu'il fallait les déclaré dans le var avant implementation ! Mais ça marche pas !
Je ne comprend pas du tout !!!
Please help me !
Merci beaucoup
A+++

2 réponses

florenth Messages postés 1023 Date d'inscription dimanche 1 août 2004 Statut Membre Dernière intervention 17 août 2008 3
28 avril 2008 à 16:00
Ben oui, c'est bien comme ça que ça marche.
Mais la faut ajouter l'unité qui contient la variable dans la clause uses de l'unité qui veut l'utiliser, ton erreur vient surement de là.
3
f0xi Messages postés 4205 Date d'inscription samedi 16 octobre 2004 Statut Modérateur Dernière intervention 12 mars 2022 35
28 avril 2008 à 19:32
Unit1
  +--> interface +uses Unit2 (interface visible dans unit1)
  +--> interface +uses Unit3 (interface visible dans unit1)

Unit2
  +--> implementation uses Unit1,Unit3 (interface visible dans Unit2)

Unit3
  +--> implementation uses Unit1,Unit2 (interface visible dans Unit3)

exemple :

Unit Unit1;

Interface {Zone publique}



Uses Unit2, Unit3;






var
  U1 : integer;



Implementation {Zone privée}

procedure TForm1.ShowUU;
begin

  LabelU2.Caption := IntToStr(Unit2.U2);

  LabelU3.Caption := IntToStr(Unit3.U3);

end;

end.
_____________________________________________


Unit Unit2;


Interface {Zone publique}



var

  U2 : integer;





Implementation {Zone privée}






Uses Unit1, Unit3;






procedure TForm2.ShowUU;

begin

  LabelU1.Caption := IntToStr(Unit1.U1);

  LabelU3.Caption := IntToStr(Unit3.U3);

end;


end.




_____________________________________________


Unit Unit3;


Interface {Zone publique}



var

  U3 : integer;





Implementation {Zone privée}







Uses Unit1, Unit2;






procedure TForm3.ShowUU;

begin

  LabelU1.Caption := IntToStr(Unit1.U1);

  LabelU2.Caption := IntToStr(Unit2.U2);

end;


end.



                         

<hr size="2" width="100%" />
0
Rejoignez-nous