Autor Beitrag
rafi@work
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 147

Win2000 Prof
D7 Enterprise
BeitragVerfasst: Mi 30.07.03 10:21 
Hi

wie kann ich prüfen ob eine betimmte Einstellung leer ist in einem ini-file? Wenn die Einstellung leer ist, möchte ich gerne eine Prozedur aufrufen. Kann mir jemand sagen wie ich das anstellen kann? Danke.

gruss
Cyrus
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 56



BeitragVerfasst: Mi 30.07.03 10:48 
lade dein ini file in eine variable vom typ Tinifiles rein
und lese dort aus den sections die werte raus mit "readstring" oder "readinteger" wenn der gelesen String '' ist dann ist er leer wenn der gelesen int 0 ist der eintrag auch leer ausser 0 hat ne bedeutung z.b bei gespeicherten schrift farben

Greetz Cyrus

_________________
Wer glaub er ist, hört auf zu werden!
Delphi Rulez!!!
rafi@work Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 147

Win2000 Prof
D7 Enterprise
BeitragVerfasst: Mi 30.07.03 10:50 
könntest du mir ein kleines Beispiel geben. Wäre sehr froh darüber.
Cyrus
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 56



BeitragVerfasst: Mi 30.07.03 11:19 
Sections ist der teil welcher im ini file [NameDerSection] so geschrieben ist und die werte sind dann unter der Section bis ne neue Section kommt.
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:
uses inifiles
...
procedure TForm1.ButtonOpenClick(Sender: TObject);
var ini:Tinifile;
begin
  if OpenDialog.Execute then
  begin
    ini:=Tinifile.Create(OpenDialog.FileName);
    if ini.ReadString('SectionName','StringName','') ='' then
    begin
      //Anwesiung wenn das Feld Leer ist
    end
    else
    begin
        //Anwesiung wenn das Feld nicht Leer ist     
    end;

    if ini.ReadInteger('SectionName','IntName','') = 0 then
    begin
      //Anwesiung wenn das Feld Leer ist (wert = 0)
    end
    else
    begin
        //Anwesiung wenn das Feld nicht Leer ist (Wert <> 0)     
    end;
    ini.free;
end;

Greetz Cyrus

_________________
Wer glaub er ist, hört auf zu werden!
Delphi Rulez!!!
rafi@work Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 147

Win2000 Prof
D7 Enterprise
BeitragVerfasst: Mi 30.07.03 11:25 
:D danke vielmal Cyrus! Die allerletzte Frage: Wie könnte ich jetzt zum beispiel eine Prozedur aufrufen?
Cyrus
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 56



BeitragVerfasst: Mi 30.07.03 11:27 
ausblenden Quelltext
1:
  namederprocedure(parameter);					


Parameter brauchst du nur wenn die procedure welche hat

Greetz Cyrus

_________________
Wer glaub er ist, hört auf zu werden!
Delphi Rulez!!!
rafi@work Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 147

Win2000 Prof
D7 Enterprise
BeitragVerfasst: Mi 30.07.03 11:37 
ich möchte diese Prozedur aufrufen, klappt aber irgendwie nicht..


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:
procedure TPingThread.Execute;
var
  CurrentTimeStamp : string;
  CtiConfigIni : TIniFile;
begin
  if FPing.Address <> '' then
  begin

  //Bei bestehendem Log, Text in Log schreiben unter FLogPath
  if fileexists(FLogPath) then LogList.LoadFromFile(FLogPath);
  LogList.Add('*******************************************');
  LogList.Add('            Deskphone Gestartet');
  LogList.Add('*******************************************');
  while NOT Terminated do
  begin
    //bei fehlgeschlagenem Ping, Text in Log schreiben
    If FPing.Ping = 0 then
    begin
      CurrentTimeStamp := FormatDateTime('dd.mm.yyyy hh:mm:ss" Host %s wurde nicht erreicht',Now);
      Loglist.Add(Format(CurrentTimeStamp,[FPing.Address]));
      LogList.SaveToFile(FLogPath);
    end;
      Sleep(FInterval*1000)
  end;
  end;
end;
derDoc
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 623

Win Vista Prof
D2007 Prof
BeitragVerfasst: Mi 30.07.03 12:19 
Du musst den Thread ja auch erst erschaffen.

ausblenden Delphi-Quelltext
1:
TPingThread.Create(Parameter);					

_________________
MfG derDoc
There are only 10 types of people: those who understand binary and those who don't.
rafi@work Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 147

Win2000 Prof
D7 Enterprise
BeitragVerfasst: Mi 30.07.03 12:27 
wo erschaffe ich den genau?
derDoc
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 623

Win Vista Prof
D2007 Prof
BeitragVerfasst: Mi 30.07.03 12:35 
Angenommen, du hast einen Start-Knopf, dann rufst du bei dessen Ereignis onClick die Prozedur TPingThread.Create(Parameter); auf

_________________
MfG derDoc
There are only 10 types of people: those who understand binary and those who don't.
rafi@work Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 147

Win2000 Prof
D7 Enterprise
BeitragVerfasst: Mi 30.07.03 12:42 
ich habe den Thread in der Prozedur erstellt:

ausblenden Delphi-Quelltext
1:
TPingThread.Create(CfgIpAddressA,CfgLogNameA,PingInterval);					


Und dann rufe ich ihn so auf:

ausblenden Delphi-Quelltext
1:
TPingThread(CfgIpAddressA,CfgLogNameA,PingInterval);					


dies geht aber nicht :(

Fehler-Meldung:
[Fehler] NetworkPingMain.pas(197): ')' erwartet, aber ',' gefunden[/code]
derDoc
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 623

Win Vista Prof
D2007 Prof
BeitragVerfasst: Mi 30.07.03 13:17 
Dann nimmst du eine Variable vom Typ TPingThread und übergibst ihr die Sache mit dem Create:

ausblenden Delphi-Quelltext
1:
PingThread := TPingThread.Create(CfgIpAddressA,CfgLogNameA,PingInterval);					

_________________
MfG derDoc
There are only 10 types of people: those who understand binary and those who don't.
rafi@work Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 147

Win2000 Prof
D7 Enterprise
BeitragVerfasst: Mi 30.07.03 13:23 
was bin ich nur für ein nörgel, aber der aufruf klappt leider immer noch nicht, bitte hab einwenig geduld mit mir...

Aufruf:
ausblenden Quelltext
1:
TPingThread(CfgIpAddressA,CfgLogNameA,PingInterval);					


Fehler-Meldung:
[Fehler] NetworkPingMain.pas(197): ')' erwartet, aber ',' gefunden[/code]
derDoc
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 623

Win Vista Prof
D2007 Prof
BeitragVerfasst: Mi 30.07.03 13:34 
Tut mir leid, aber ich weiß nicht, was du mit diesem Aufruf bezwecken willst.

Wenn du den Thread jetzt starten willst, und im constructor Suspended nicht auf false gesetzt hast, muss du mit
ausblenden Delphi-Quelltext
1:
PingThread.Resume;					

den Thread starten.

_________________
MfG derDoc
There are only 10 types of people: those who understand binary and those who don't.