Autor Beitrag
delphist
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 64

WIN XP, 98, 95; SUSE LINUX 8.1, 6.1, 6.0

BeitragVerfasst: Sa 30.08.03 18:22 
Hallo!
Ich möchte auf in einem anderen Formular erstellten Daten zugreifen!
Aber das klappt nicht!
Wie funktioniert das?
Muss ich dazu die Daten immer in ein Edit, Listbox ... zwischenspeichern?
Bis habe ich das immer so gemacht und Visible auf False gestellt!
Gibt es da keine elegantere Lösung?
mfg delphist

_________________
3w + freehostlist + de
3w + bild-stoerung + de
UGrohne
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Veteran
Beiträge: 5502
Erhaltene Danke: 220

Windows 8 , Server 2012
D7 Pro, VS.NET 2012 (C#)
BeitragVerfasst: Sa 30.08.03 18:25 
Auf welche Daten willst Du denn zugreifen?
Um das dann zu machen, musst Du nur die andere Unit in die uses-Liste oben hinzufügen, dann den Formularnamen. gefolgt von dem was Du willst.
Wenn Du Variablen innerhalb der Unit hast, musst Du sicherstellen, dass sie im public-Bereich deklariert sind, sonst hast Du von außen keinen Zugriff drauf.
delphist Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 64

WIN XP, 98, 95; SUSE LINUX 8.1, 6.1, 6.0

BeitragVerfasst: Sa 30.08.03 18:49 
Hallo!
Kannst du mir das Bitte an einem Beispiel erläutern?
So komme ich nämlich nicht weiter!
mfg delphist

_________________
3w + freehostlist + de
3w + bild-stoerung + de
FeG
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 77

Win XP Home, SuSE Linux 8.2 Prof
D3 Prof, D7 Prof
BeitragVerfasst: Sa 30.08.03 18:54 
Hallo,

du musst in der Deklaration des zweiten Forms unter "public" die gewünschten Variablen eintragen und im Hauptform (oder da, wo du auf die Variablen zugreifen willst...) nach "Implementation" uses Form2 {hier den Dateinamen des Formulars mit den Variablen};
eintragen

MfG,
FeG
delphist Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 64

WIN XP, 98, 95; SUSE LINUX 8.1, 6.1, 6.0

BeitragVerfasst: Sa 30.08.03 19:12 
Also wenn ich die var Anweisung nach der public Anweisung eifüge sagt er end erwartet!
Kannst du mir nicht bitte an einem kl. beispiel es zeigen???
mfg delphist

_________________
3w + freehostlist + de
3w + bild-stoerung + de
UGrohne
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Veteran
Beiträge: 5502
Erhaltene Danke: 220

Windows 8 , Server 2012
D7 Pro, VS.NET 2012 (C#)
BeitragVerfasst: Sa 30.08.03 19:25 
Ohne var!!! Schau Dir mal nach einem buch, damit Du die die Pascal-Syntax, besonders des Headers und von klassen verstehst.
ausblenden Delphi-Quelltext
1:
2:
3:
public
  einvar:integer;
 ....
FeG
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 77

Win XP Home, SuSE Linux 8.2 Prof
D3 Prof, D7 Prof
BeitragVerfasst: Sa 30.08.03 19:27 
delphist hat folgendes geschrieben:
Also wenn ich die var Anweisung nach der public Anweisung eifüge sagt er end erwartet!

Dann braucht er halt entweder noch ein "end;" oder ein ";"... sind die Delphi-Compilermeldungen denn so kompliziert??

Probier das mal aus, wenn's net klappt, poste den betreffenden Quelltext...

MfG,
FeG
delphist Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 64

WIN XP, 98, 95; SUSE LINUX 8.1, 6.1, 6.0

BeitragVerfasst: Sa 30.08.03 19:27 
UGrohne hat folgendes geschrieben:
Ohne var!!! Schau Dir mal nach einem buch, damit Du die die Pascal-Syntax, besonders des Headers und von klassen verstehst.
ausblenden Delphi-Quelltext
1:
2:
3:
public
  einvar:integer;
 ....

Ja, leider wird in den Delphi Buechern nur einen Zeichne ein Edit auf die Malfläche gesagt und nicht den eigentlichen Syntax!
Und ich muss sagen der Syntax ist einfach viel besser als bei anderen Sprachen!
Vergleich: VisualBasic!
mfg delphist

_________________
3w + freehostlist + de
3w + bild-stoerung + de
hansa
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3079
Erhaltene Danke: 9



BeitragVerfasst: Sa 30.08.03 19:27 
ausblenden Delphi-Quelltext
1:
;					

_________________
Gruß
Hansa
delphist Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 64

WIN XP, 98, 95; SUSE LINUX 8.1, 6.1, 6.0

BeitragVerfasst: Sa 30.08.03 19:28 
hansa hat folgendes geschrieben:
ausblenden Delphi-Quelltext
1:
;					

Nein!
Das hatte ich nicht vergessen!
Soviel weiß ich schon von Delphi!!!
mfg delphist

_________________
3w + freehostlist + de
3w + bild-stoerung + de
delphist Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 64

WIN XP, 98, 95; SUSE LINUX 8.1, 6.1, 6.0

BeitragVerfasst: Sa 30.08.03 19:34 
Hallo!
Jetzt sagt er in der Unit, wo ich auf die Variable zugreifen will, dass er die Var nicht kennt!
Was jetzt?
Ich habe in dieser Unit nach implementation und uses dateunauswahl; eingegeben[/b]

_________________
3w + freehostlist + de
3w + bild-stoerung + de
hansa
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3079
Erhaltene Danke: 9



BeitragVerfasst: Sa 30.08.03 19:35 
das war auch zu kurz. 8) Ich weiß wo dran es liegt. Du mußt das ganze nur im Interface-Teil deklarieren. Und üben mußt Du auch noch, sonst wird das nichts. D.h.: setze erst mal eine Variable i: integer; da hin. Mit uses Form1; kommt die dann in eine andere Unit. Und wenn das compiliert, dann gent es weiter.

_________________
Gruß
Hansa
delphist Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 64

WIN XP, 98, 95; SUSE LINUX 8.1, 6.1, 6.0

BeitragVerfasst: Sa 30.08.03 19:38 
hansa hat folgendes geschrieben:
das war auch zu kurz. 8) Ich weiß wo dran es liegt. Du mußt das ganze nur im Interface-Teil deklarieren. Und üben mußt Du auch noch, sonst wird das nichts. D.h.: setze erst mal eine Variable i: integer; da hin. Mit uses Form1; kommt die dann in eine andere Unit. Und wenn das compiliert, dann gent es weiter.

Gleich Problem!
Wie in meinem letzten Beitrag beschrieben:
VARIABEL UNDEFINIERT!
mfg delphist

_________________
3w + freehostlist + de
3w + bild-stoerung + de
hansa
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3079
Erhaltene Danke: 9



BeitragVerfasst: Sa 30.08.03 19:44 
steht in der ein Unit so was in der Richtung:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
Unit Unit2;


Interfaces 

uses Unit1;

var i : integer;

implementation;

.....



:?: :?:

_________________
Gruß
Hansa
delphist Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 64

WIN XP, 98, 95; SUSE LINUX 8.1, 6.1, 6.0

BeitragVerfasst: Sa 30.08.03 20:50 
hansa hat folgendes geschrieben:
steht in der ein Unit so was in der Richtung:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
Unit Unit2;


Interfaces 

uses Unit1;

var i : integer;

implementation;

.....

:?:

Jetzt kommt keine Fehlermeldung, aber die Variabel ist wieder leer!
Gibt es keine funktionierende Lösung!
mfg delphist


:?:

_________________
3w + freehostlist + de
3w + bild-stoerung + de
hansa
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3079
Erhaltene Danke: 9



BeitragVerfasst: Sa 30.08.03 20:54 
dann poste mal den Quelltext. Antwort kriegst Du dann sofort von dem, der es zuerst sieht. 8)

_________________
Gruß
Hansa
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Sa 30.08.03 20:57 
Ich habe ein wenig den Überblick verloren, was genau gefragt ist. Ich versuche es einfach mal. Folgendes sei die Unit, die deine Form enthält:
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:
unit Unit1;

interface

uses
{...}

type
  TForm1 {...}

var
  Form1: TForm1;

implementation

{$R *.dfm}

uses unit2;

procedure TForm1.FormCreate(Sender: TObject);
begin
  ShowMessage(IntToStr(unit2.i));
end;

end.

Und folgendes ist Unit2, deren Variable "i" verwendet werden soll:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
unit Unit2;

interface

var i : INTEGER = 355;

implementation

end.

So, das funktioniert bei mir, wenn du die {...} so ergänzt, wie sie von Delphi erzeugt werden. Im FormCreate kannst Du auch das "unit2" vor dem i weglassen, aber ich finde das übersichtlicher.

Hoffe, nicht am Thema vorbei geschrieben und geholfen zu haben.

MfG
Peter

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
delphist Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 64

WIN XP, 98, 95; SUSE LINUX 8.1, 6.1, 6.0

BeitragVerfasst: Sa 30.08.03 21:19 
Also das Thema hast du chon richtig erwischt!
Aber bei mir klappt es so immer noch nicht!
Er sagt weiterhin er kennt die Variabel nicht!
mfg delphist

_________________
3w + freehostlist + de
3w + bild-stoerung + de
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Sa 30.08.03 21:52 
Sorry, aber bis auf die Sachen, die ich mit {...} gekürzt habe, läuft das Programm so bei mir. Poste doch mal Deine beiden Units. Vielleicht findet sich dann der Fehler. (Tarnfehler, mal ganz was neues. Kann man hinter den feindlichen Linien abwerfen und dann funktionieren deren Geräte nicht mehr! :lol: )

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
delphist Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 64

WIN XP, 98, 95; SUSE LINUX 8.1, 6.1, 6.0

BeitragVerfasst: So 31.08.03 11:35 
Funzt immer noch nicht!
Bin gestern erstmal schlafen gegangen aus lauter Verzweiflung!
Naja, man hat doch anfangs zum Beispiel in Delphi 1 noch eigene Dialogboxen gemacht! Wie hat manj damals zum Beispiel den Datienamen zurückgegeben?
mfg delphist

_________________
3w + freehostlist + de
3w + bild-stoerung + de