Autor Beitrag
death-adders
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 82

Vista
Turbo Delphi Explorer
BeitragVerfasst: So 26.02.06 16:07 
hi @ all!!

Also wie nun schon die überschrift sagt, möchte ich wissen, wo man die variablen deklariert, wenn sie:

-in jeder "procedure" gültig sein soll

-nur innerhalb einer "procedure" gültig sein soll.

Außerem müsste ich wissen wo ich ne dll deklariere, bzw wie ich ein extra modul erstellen kann, um dieses dort zu tun!


Vielen dank für eure Hilfe!!
Henry
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 619

WinXP Prof. SP3
D6 Prof.
BeitragVerfasst: So 26.02.06 18:58 
Global (für alle Proceduren und Functionen:
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
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs;

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

var
  Form1: TForm1;
  //hier Globale Veriablen

implementation

{$R *.dfm}

end.


Nur für die Procedure:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
Procedure test;
VAR //Hier die Variablen nur für die Procedure
Begin
...
End;


Ich hoffe es hilft Dir weiter ;)

_________________
mfg Henry
death-adders Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 82

Vista
Turbo Delphi Explorer
BeitragVerfasst: So 26.02.06 19:37 
Jo, danke, hat noch jemand ne Idee wie das mit den dll's funktioniert?
Henry
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 619

WinXP Prof. SP3
D6 Prof.
BeitragVerfasst: So 26.02.06 19:49 
Was meinst Du genau? Auch die Declaration der Variablen, oder das einbinden der Funktionen?

_________________
mfg Henry
death-adders Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 82

Vista
Turbo Delphi Explorer
BeitragVerfasst: Mo 27.02.06 15:47 
Also ich habe ne dll hier und die zeile die ich eingeben muss, damit mir beispielstweise der befehl "OPENCOM" zur verfügung steht. Ich weiß nur nicht so recht wo die stehen muss
Henry
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 619

WinXP Prof. SP3
D6 Prof.
BeitragVerfasst: Mo 27.02.06 18:28 
HAllo,

das kannst Du in einer extra Unit machen wo Du alle Funktionen der DLL Statisch einbindest. Das würde dann ungefähr so aussehen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
unit UnitDLLFunktionen;

interface

 Procedure Procedure1(Aktiv:Boolean); stdCall; external 'DLLNAME.dll';
 Procedure Procedure2; stdCall; external 'DLLNAME.dll';

implementation

end.


Diese Unit kannst Du dann in dein Programm einbinden und die Funktionen wie gewohnt aufrufen.

_________________
mfg Henry
death-adders Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 82

Vista
Turbo Delphi Explorer
BeitragVerfasst: Mo 27.02.06 18:47 
ja, genau da liegt der haken, wie erstelle ich die extra unit und wie binde ich sie ein?
Blackheart666
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: Mo 27.02.06 18:56 
Ich schätze mal, das du noch lange nicht soweit bist um Dll's überhaupt gebrauchen zu können - also was solls !?
Henry
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 619

WinXP Prof. SP3
D6 Prof.
BeitragVerfasst: Mo 27.02.06 19:10 
user profile icondeath-adders hat folgendes geschrieben:
ja, genau da liegt der haken, wie erstelle ich die extra unit und wie binde ich sie ein?


Eine extra Unit kannst Du erstellen indem Du über Datei|Neu|Unit erstellen. Da bindest Du wie oben im Beispiel die Funktionen und Proceduren ein (die Du ja deiner Aussage nach hast).
Einbinden kannst Du die Unit ganz einfach indem Du den Namen der Unit unter Uses der Units des Programmes mit einträgst in der Du die Funktionen verwenden möchtest.

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:
unit Unit1;

interface

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

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

var
  Form1: TForm1;

implementation

{$R *.dfm}

end.

_________________
mfg Henry
Blackheart666
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: Mo 27.02.06 19:20 
Das Hilft doll weiter , wenn man keine Ahnung hat !
(Wenn schon denn schon - ganz von vorn).
Jetzt steh Ich hier Ich armer T....
Henry
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 619

WinXP Prof. SP3
D6 Prof.
BeitragVerfasst: Mo 27.02.06 19:36 
user profile iconBlackheart666 hat folgendes geschrieben:
Das Hilft doll weiter , wenn man keine Ahnung hat !
(Wenn schon denn schon - ganz von vorn).
Jetzt steh Ich hier Ich armer T....


Wie würdest Du es denn noch anders beschreiben?
Kannst meinene (knappen) Ausführungen ja ergänzen ;)

_________________
mfg Henry
Blackheart666
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: Mo 27.02.06 19:43 
Das sollte kein Angriff sein, aber dachte mir schon das dieses falsch rüberkommt.
Alles Top erklärt ... aber vom Fragesteller Wo Deklariere Ich Variablen ... Dll ? das kann nur zu schwer sein !!!
Henry
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 619

WinXP Prof. SP3
D6 Prof.
BeitragVerfasst: Mo 27.02.06 19:52 
Ich gehe einfach mal davon aus das er sich noch einmal melden wird wenn noch was unklar ist.
Dann kann man ja versuchen Schritt für Schritt weiter aufzulösen.
Bin ja auch kein Profi ;)

_________________
mfg Henry
death-adders Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 82

Vista
Turbo Delphi Explorer
BeitragVerfasst: Mo 27.02.06 20:07 
danke leute, nu is alle klar, ich habe die dll schon mehrmals benutzt, nur halt unter VB und nicth in delphi!
Henry
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 619

WinXP Prof. SP3
D6 Prof.
BeitragVerfasst: Mo 27.02.06 20:23 
Freut mich das ich helfen konnte

_________________
mfg Henry
Blackheart666
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: Mo 27.02.06 20:24 
Kleier Auszug aus deiner Source wäre nicht schlecht, für andere die vieleicht mal das gleiche Problem haben.
death-adders Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 82

Vista
Turbo Delphi Explorer
BeitragVerfasst: Mo 27.02.06 21:01 
So hier ein kleine example!

Wen jemand fragen hat, kann er/sie ruhig mich an mailen!




ausblenden volle Höhe 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:
29:
30:
31:
32:
33:
34:
35:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, unit2, StdCtrls; //hier habe ich die unit 2 eingebunden, in der z.B. .dll declarationen sind

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
var variable1, variable2 :integer; //hier globale - also für jede fuction/procedure gültige variablen declarieren
implementation

{$R *.dfm}



procedure TForm1.Button1Click(Sender: TObject);
var variable3 :real; //hier variablen, die nur in dieser function gültig sein sollen declarieren
  begin
    variable3 := 27;
     showmessage ('variable3 enthält nun den wert 27')
  end;

end.


Moderiert von user profile iconraziel: Code- durch Delphi-Tags ersetzt
Blackheart666
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: Mo 27.02.06 21:12 
Nicht schlecht aber das einzige was du getan hast ist die Unit2 mit anzugeben und das mach Delphi auch automatisch.
Versuch dann mal auf verschiedene Variablen innerhalb beider Units zuzugreifen, das wird nicht funktionieren.