Autor Beitrag
day
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 107



BeitragVerfasst: So 25.07.04 17:24 
Hallo

Ich würde gerne im Initialization - Abschnitt ein Object erzeugen und Zuweisen. Aber irgendwie klappt das nicht so ganz. Wo liegt der Fehler :?:

ausblenden Quelltext
1:
2:
3:
initialization

Settings := TSettings.Create();
MathiasSimmack
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: So 25.07.04 17:42 
Hast du auch eine Fehlermeldung für uns? Oder geht es nur ganz einfach nicht, ohne dass dein Compiler sich über irgendetwas beschwert? Normalerweise wüsste ich nämlich nicht, was an diesem Stück Code falsch sein soll. Darum die Frage nach mehr Informationen.
day Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 107



BeitragVerfasst: So 25.07.04 17:44 
die fehlermeldung lautet: [Fehler] config.pas(43): Undefinierter Bezeichner: 'm_Settings'

und hier noch der gesamte code

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:
36:
37:
38:
39:
40:
41:
42:
43:
44:
unit config;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, xmldom, XMLIntf, StdCtrls, Buttons, msxmldom, XMLDoc,
  GeneralSettings,oxmldom;

type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Button1: TButton;
    Label1: TLabel;
    procedure Button1Click(Sender: TObject);
  private
    m_Settings : TSettings;
    procedure init();
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.init();
Begin
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  m_Settings.readValuesFromFile('Configuration.xml');
  Label1.Caption := m_Settings.getParameter('ServerIP');
end;

initialization
m_Settings := TSettings.Create;

end.


Moderiert von user profile iconMotzi: Delphi-Tags hinzugefügt.
Elite
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: So 25.07.04 18:19 
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:
36:
37:
38:
39:
40:
41:
42:
43:
44:
unit config;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, xmldom, XMLIntf, StdCtrls, Buttons, msxmldom, XMLDoc,
  GeneralSettings,oxmldom;

type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Button1: TButton;
    Label1: TLabel;
    procedure Button1Click(Sender: TObject);
  private
    procedure init();
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;
  m_Settings : TSettings; // <--- Hier deklarieren

implementation

{$R *.dfm}

procedure TForm1.init();
Begin
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  m_Settings.readValuesFromFile('Configuration.xml');
  Label1.Caption := m_Settings.getParameter('ServerIP');
end;

initialization
m_Settings := TSettings.Create;

end.
MathiasSimmack
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: So 25.07.04 18:26 
Na, da war ich ja fast ein Hellseher. Äh, "m_Settings" ist eine Form-bezogene Variable. Logisch, dass du da eine Fehlermeldung bekommst. Ich weiß im Moment nicht, ob man initialization-Teil schon auf Form-Variablen zugreifen kann. Ich bin nicht sicher, würde es bezweifeln und dir daher empfehlen, "m_Settings" als globale Variable zu deklarieren und aus der Form herauszunehmen.
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: So 25.07.04 18:28 
MathiasSimmack hat folgendes geschrieben:
Ich bin nicht sicher, würde es bezweifeln

Nein, kann man nicht.. bzw. kann man schon, aber nur im Zusammenhang mit einer netten Fehlermeldung.. ;)

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!
Keldorn
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 2266
Erhaltene Danke: 4

Vista
D6 Prof, D 2005 Pro, D2007 Pro, DelphiXE2 Pro
BeitragVerfasst: So 25.07.04 18:28 
Hallo

wenn du die m_settings als Eigenschaft deiner Form deklarierst, kanst du nicht im initialization so darauf zu greifen.

besser wäre, die M_settings im Formcreate zu erzeugen und bei Fromdestroy wieder freizugeben.

Mfg Frank

_________________
Lükes Grundlage der Programmierung: Es wird nicht funktionieren.
(Murphy)
day Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 107



BeitragVerfasst: So 25.07.04 19:33 
danke für eure hilfe