Autor Beitrag
Luncustaf
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 324

Win 2k
D7 Ent.
BeitragVerfasst: Di 22.04.03 15:12 
hi,


ich hab hier den code

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
   try
     openq.open;
   except
     AssignFile(f,'Log.txt');
     {$i-} {Append(f); {$i+}
     if IOResult <> 0 then Halt;
     Writeln(f,'No Connection to Openplan-Datebase at '+TimeToStr(time)+' on '+DateToStr(date));
     CloseFile(f);
   end;//try


wenn nun zb die datenbank nicht an ihrem platz ist kommt eine exception as die datenbank nicht da ist - aber weiso führt er mir mei nexcept nicht aus wenn das try net klappt?

kann ich die message auch irgendwie anners abfangen?


gr€€tz
a.C.k
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 93

WIN 2000
Delphi 6 Enterprise ; Delphi 7 Studio
BeitragVerfasst: Di 22.04.03 16:24 
Probiere es mal so:

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
   try 
     openq.open; 
   except 
     begin
       AssignFile(f,'Log.txt'); 
       {$i-} {Append(f); {$i+} 
       if IOResult <> 0 then Halt; 
       Writeln(f,'No Connection to Openplan-Datebase at '+TimeToStr(time)+' on '+DateToStr(date)); 
       CloseFile(f);
     end; 
   end;//try

_________________
Wer nicht gerne denkt, sollte wenigstens von Zeit zu Zeit seine Vorurteile neu gruppieren.
tommie-lie
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 4373

Ubuntu 7.10 "Gutsy Gibbon"

BeitragVerfasst: Di 22.04.03 16:47 
nein, daran liegt es nicht. Except braucht ein begin..end ebenso wenig wie ein try oder ein finally.
Aber woran es hier liegt, sehe ich auch nicht. Sicher, daß openq.open eine Exception auslöst?

_________________
Your computer is designed to become slower and more unreliable over time, so you have to upgrade. But if you'd like some false hope, I can tell you how to defragment your disk. - Dilbert
GruppeCN
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 322



BeitragVerfasst: Di 22.04.03 17:01 
Wie wäre es , wenn du dein Programm mal kompilierst und dann startest(nicht aus Delphi)???

_________________
Warum sind die Sachen, die du suchst, immer da, wo du zuletzt nachsiehst?
Weil du aufhörst zu suchen, wenn du sie gefunden hast.
Udontknow
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2596

Win7
D2006 WIN32, .NET (C#)
BeitragVerfasst: Di 22.04.03 17:15 
Hi!

Was ist denn, wenn du in den finally-Block einfach nur "ShowMessage('Eine Exception ist aufgereten!');" reinschreibst?
Ich vermute einfach mal, daß du aus Versehen eine weitere Exception innerhalb des except-Blocks auslöst (z.B. weil die Datei 'log.txt' nicht existiert).

Nachtrag: Sehe gerade, daß du den IO-Exception-Mechanismus abschaltest und statt dessen im Fehlerfalle das Programm per Halt beendest. Beendet sich denn das Programm?

Cu, :)
Udontknow
MSCH
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1448
Erhaltene Danke: 3

W7 64
XE2, SQL, DevExpress, DevArt, Oracle, SQLServer
BeitragVerfasst: Di 22.04.03 17:28 
brrrr. Try/except Blöcke brauchen kein begin/end Statemant. Weiterhin würd ich den halt() Befehl aus dem Block nehmen, das ist wir Auto fahren mit 100 Sachen gegen die Wand.
grez. msch
Udontknow
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2596

Win7
D2006 WIN32, .NET (C#)
BeitragVerfasst: Di 22.04.03 17:33 
@MSCH: Full ACK. Zumindest eine Meldung sollte in irgendeiner Weise aufgeblendet werden.

Was sagen eigentlich die Breakpoints? Ist denn IOResult<>0?

Cu,
Udontknow
Luncustaf Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 324

Win 2k
D7 Ent.
BeitragVerfasst: Di 22.04.03 19:31 
also mein problem ist das er gar nicht in den except block geht wenn ich durch debugge sonder bringtm ir beim open das er die db net finden kann - wenn ich den namen der db zb absichtlich verändere - das ist dann so gewollt und ich denke mir (hab noch net viel mit try/except gemacht) das er dann in den except teil sprigen muss.

das was im ecxept teil steht ersmal nicht weiter beachten -ä nder ich noch ab. mir gehts ersmal darum das er mir da gar net reingeht und ich mich frage wieso.

wenn ich try/ecxept richtig verstanden habe dann ist das grad für solche sachen das wenn ne meldung vom programm kommt wie zb database net gefunden das ich dann die ausgabe der fehlermeldung kontrolliere oder hab ich da was falsch verstanden


gr€€tz