Autor Beitrag
colaka
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 200
Erhaltene Danke: 4

Win XP, W7
Delphi 2005 Prof.
BeitragVerfasst: Sa 24.09.11 11:12 
Hallo,

egal, ob ich die Dialogabfrage mit ja oder mit nein beantworte, erscheint immer ShowMessage('Weitermachen'). Ich will aber nur weitermachen, wenn Update false ist.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
var
  Update : Boolean;
  DatumUpdateFTP, DatumUpdate : TDateTime;
begin
  Update := false;
  if (DatumUpdateFTP - DatumUpdate) > 0.001 then // kann ProgrammUpdate durchgeführt werden
    if MessageDlg('Es gibt eine verbesserte Programmversion.' + #10#13
      + 'Möchten Sie das Programm jetzt aktualisieren?', mtConfirmation, [mbYes, mbNo], 0)
      = mrYes then
    begin
      ShowMessage('Update');
      Update := true;
    end
  if not Update then
  begin
    ShowMessage('Weitermachen');
  end;


Entweder habe ich immer noch ein Problem mit den Boolean-Werten oder mit MessageDlg, jedenfalls kann ich den Fehler einfach nicht finden und wäre für jeden Hinweis dankbar.

Danke Ebi
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Sa 24.09.11 11:30 
Moin!

Warum rechnest du mit den Datumswerten? :nixweiss:

Ich würde das so machen:
ausblenden Delphi-Quelltext
1:
  if (DatumUpdateFTP > DatumUpdate) then // kann ProgrammUpdate durchgeführt werden					
cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
colaka Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 200
Erhaltene Danke: 4

Win XP, W7
Delphi 2005 Prof.
BeitragVerfasst: Sa 24.09.11 11:35 
Hallo,

weil durch den Programmablauf manchmal kleine Zeitdifferenzen an der 5. Stelle oder noch später auftreten.
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Sa 24.09.11 11:39 
Moin!

user profile iconcolaka hat folgendes geschrieben Zum zitierten Posting springen:
weil durch den Programmablauf manchmal kleine Zeitdifferenzen an der 5. Stelle oder noch später auftreten.
Das ist beim Datentyp TDateTime "normal". :nixweiss: Zeig mal den Code, in dem du die Inhalte dieser Variablen bestimmst. Oder anders: was sollte denn drin stehen?

An den Boolean liegt´s jedenfalls nicht, da kann man doch kaum was falsch machen. Sobald du den Hinweis kriegst "Update", wird auch das zweite Showmessage unterdrückt. Wenn nicht, ist deine CPU kaputt. ;)

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
colaka Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 200
Erhaltene Danke: 4

Win XP, W7
Delphi 2005 Prof.
BeitragVerfasst: Sa 24.09.11 11:50 
Hallo,

DaumUpdate hol ich mir aus der Ini-Datei:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
  IniDat := TIniFile.Create(FHaupt.Datenpfad+'Quantall.ini');
  try
    DatumUpdate := IniDat.ReadFloat('Aktuell''Update'1);
    finally
      IniDat.Free;
  end;


und DatumUpdateFTP hol ich mir vom Server:
ausblenden Delphi-Quelltext
1:
    DatumUpdateFTP := IdFTP.FileDate('update.dat');					


Wenn ich die Dialogabfrage mit "nein" beantworte, erscheint korrekterweise ShowMessage('weitermachen').
Aber wenn ich sie mit "ja" beantworte, erscheint zuerst ShowMessage('Update') und dann auch noch ShowMessage('weitermachen'). Und da muß doch irgendwo ein Fehler sein.

Danke Ebi
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Sa 24.09.11 11:55 
Moin!

user profile iconcolaka hat folgendes geschrieben Zum zitierten Posting springen:
Wenn ich die Dialogabfrage mit "nein" beantworte, erscheint korrekterweise ShowMessage('weitermachen').
OK.

user profile iconcolaka hat folgendes geschrieben Zum zitierten Posting springen:
Aber wenn ich sie mit "ja" beantworte, erscheint zuerst ShowMessage('Update') und dann auch noch ShowMessage('weitermachen'). Und da muß doch irgendwo ein Fehler sein.
Hmm... :gruebel: Benenne mal die Variable um, nicht dass das da mit irgendwelchen Formulareigenschaften oder globalen Variablen kollidiert oder so. :?
ausblenden Delphi-Quelltext
1:
2:
var
  MyUpdate : Boolean;
cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.

Für diesen Beitrag haben gedankt: colaka
colaka Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 200
Erhaltene Danke: 4

Win XP, W7
Delphi 2005 Prof.
BeitragVerfasst: Sa 24.09.11 12:01 
Hallo,

das war wohl das Problem. Jetzt funktioniert alles so, wie es soll.

Tausend Dank.
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Sa 24.09.11 12:09 
Moin!

user profile iconcolaka hat folgendes geschrieben Zum zitierten Posting springen:
das war wohl das Problem. Jetzt funktioniert alles so, wie es soll.
:beer:

Einen Tipp habe ich aber noch:
user profile iconcolaka hat folgendes geschrieben Zum zitierten Posting springen:
ausblenden Delphi-Quelltext
1:
2:
3:
  IniDat := TIniFile.Create(FHaupt.Datenpfad+'Quantall.ini');
  try
    DatumUpdate := IniDat.ReadFloat('Aktuell''Update'1);
Es gibt auch eine Methode .ReadDateTime(), das würde ich nicht explizit auf einen Float zwingen. :idea:

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.

Für diesen Beitrag haben gedankt: colaka