Autor Beitrag
GR-Thunderstorm
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 206



BeitragVerfasst: Sa 13.05.06 14:13 
Hi Leutz,
ich hab mal ne generelle Frage:
Angenommen in Unit1 deklariere ich ne Variable X als integer, gilt diese Variable dann auch in allen anderen Units dieses Programs? Wenn nicht, ist es auf andere Weise machbar?

DANKE!
Xion
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
EE-Maler
Beiträge: 1952
Erhaltene Danke: 128

Windows XP
Delphi (2005, SmartInspect), SQL, Lua, Java (Eclipse), C++ (Visual Studio 2010, Qt Creator), Python (Blender), Prolog (SWIProlog), Haskell (ghci)
BeitragVerfasst: Sa 13.05.06 14:14 
wenn du die Unit unter uses einbindest funktionierts normalerweise schon.

_________________
a broken heart is like a broken window - it'll never heal
In einem gut regierten Land ist Armut eine Schande, in einem schlecht regierten Reichtum. (Konfuzius)
Tino
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Veteran
Beiträge: 9839
Erhaltene Danke: 45

Windows 8.1
Delphi XE4
BeitragVerfasst: Sa 13.05.06 14:24 
Neben dem Hinweis von Xion ist auch wichtig, das die Variable im Interface Abschnitt definiert wird und nicht im Implementation Abschnitt.
GR-Thunderstorm Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 206



BeitragVerfasst: Sa 13.05.06 18:24 
Wäre das also so richtig?

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs;

type
  TForm1 = class(TForm)
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  x:integer;          {<----- an dieser Stelle?}

implementation

uses Unit2;

{$R *.dfm}
begin
...
end.