Autor Beitrag
rizor
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 209

WIN XP
Delphi 2005 PE, Visual C++
BeitragVerfasst: Di 21.08.07 22:02 
Hi,

ich möchte eine Fehlermeldung unterdrücken.

Ich habe einen
try

except
Aufruf.

In Diesem Aufruf soll versucht werden einen String in einen Integer umzuwandeln.
Ich weiß auch genau, dass es sein kann dass es kein integer ist.
Das Programm springt auch in except aber die Meldung kommt trotzdem dass z kein integer ist.
Wie kann ich das verhindern?
ConditionZero
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 190

Win XP
Delphi 7 PE, C++ (Dev-C++), HTML+PHP (Dreamweaver MX), JavaScript(MS FrontPage)
BeitragVerfasst: Di 21.08.07 22:23 
Wie sieht denn dein try-except-Block aus?
Calculon
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 676

Win XP Professional
Delphi 7 PE, Delphi 3 PRO
BeitragVerfasst: Di 21.08.07 22:35 
Meine Glaskugel verrät mir: Die Lösung findest du hier.

Gruß

Calculon
--
Jojojoxx
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 386



BeitragVerfasst: Di 21.08.07 22:37 
Oft meldet der Compiler noch Fehlermeldungen, die aber beim Ausführen der Exe-Datei in Windows (also durch einfachen Doppelklick darauf und nicht über Delphi) nicht angezeigt werden.
Starte Die Exe-Datei mal außerhalb von Delphi.
mfg

Jojo
rizor Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 209

WIN XP
Delphi 2005 PE, Visual C++
BeitragVerfasst: Mi 22.08.07 12:51 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
try
    Num := StrToInt(CodePart[1]);
  except
    if CodePart[1] = 'D' then
      Num := 10;
    if CodePart[1] = 'Q' then
      Num := 13;
    if CodePart[1] = 'N' then
      Num := 14;
    if CodePart[1] = 'H' then
      Num := 18;
    if CodePart[1] = 'E' then
      Num := 1;
    if CodePart[1] = 'A' then
      Num := 21;
  end;


Zitat:

Meine Glaskugel verrät mir: Die Lösung findest du hier.

Gruß

Calculon


Deine Glaskugel lag falsch.

Der Fehler tritt auch auf, wenn ich die Exe starte.
Das sieht dann so aus, dass das Programm stoppt aber man nicht direkt die Fehlermeldung sieht.
Die poppt erst auf, wenn ich das Programm noch einmal anklicke.
Calculon
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 676

Win XP Professional
Delphi 7 PE, Delphi 3 PRO
BeitragVerfasst: Mi 22.08.07 13:05 
Zitat:
Das sieht dann so aus, dass das Programm stoppt aber man nicht direkt die Fehlermeldung sieht.
Die poppt erst auf, wenn ich das Programm noch einmal anklicke.


Du musst mehr Code zeigen, weil so wie es dasteht, sollte eigentlich keine Fehlermeldung kommen (wenn Num: Integer und CodePart: string).

Gruß

Calculon
--
little-wolf
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 47

WinXP
Delphi 5 Enterprise, Delphi 2006 Enterprise
BeitragVerfasst: Mi 22.08.07 13:21 
hallo rizor

user profile iconrizor hat folgendes geschrieben:
Das sieht dann so aus, dass das Programm stoppt aber man nicht direkt die Fehlermeldung sieht.
Die poppt erst auf, wenn ich das Programm noch einmal anklicke.


das kann wie auf den printscreens ersichtlich abgeschaltet werden (Delphi 5)

gruss

little-wolf
Einloggen, um Attachments anzusehen!
arj
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 378

Win XP/Vista, Debian, (K)Ubuntu
Delphi 5 Prof, Delphi 7 Prof, C# (#Develop, VS 2005), Java (Eclipse), C++, QT, PHP, Python
BeitragVerfasst: Do 23.08.07 12:38 
user profile iconrizor hat folgendes geschrieben:

Der Fehler tritt auch auf, wenn ich die Exe starte.


Also liegt es wohl nicht an dem ;)
little-wolf
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 47

WinXP
Delphi 5 Enterprise, Delphi 2006 Enterprise
BeitragVerfasst: Do 23.08.07 12:51 
oops... genauer lesen wäre wohl mal noch was... sorry... :oops:
noidic
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 851

Win 2000 Win XP Vista
D7 Ent, SharpDevelop 2.2
BeitragVerfasst: Do 23.08.07 12:55 
Ich kann da auf Anhieb keinen Fehler sehen.

Davon ab, mit TryStrToInt kannst du dir das try-except sparen.

_________________
Bravery calls my name in the sound of the wind in the night...