Autor Beitrag
theromi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 22



BeitragVerfasst: So 11.02.07 14:34 
Hi,

Folgender Quelltext:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
[...]
    plist := Tstringlist.create;
    plist.Loadfromfile('qconsole.log');

    for Loop := 1 to plist.Count-1 do
    begin
        fund := plist[Loop];
        if (fund[1] = '[') AND (fund[2] = 'M') AND (fund[3] = 'G') AND (fund[4] = ']') then
[...]


Und bei der if-Abfrage crasht das Programm, wenn die Zeile in der Textdatei leer ist :(

Meldung (ungefär ;) ): "Exeption EAccessViolation in module cstrikehelp"

Hat jemand ne Lösung?

Danke,
Roman
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: So 11.02.07 14:39 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
[...]
    plist := Tstringlist.create;
    plist.Loadfromfile('qconsole.log');

    for Loop := 1 to plist.Count-1 do
    begin
        fund := plist[Loop];
        if (fund <> '') then
        begin
          if (fund[1] = '[') AND (fund[2] = 'M') AND (fund[3] = 'G') AND (fund[4] = ']')              then
        end;

BTW: Warum arbeitest du nicht mit copy?

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
Grenzgaenger
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: So 11.02.07 14:47 
wenn du auf 'n string wahlfrei zugreifst, musste erst mal gucken, ob du zugreifen kannst...

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
[...]
    plist := Tstringlist.create;
    plist.Loadfromfile('qconsole.log');

    for Loop := 1 to plist.Count-1 do
    begin
        fund := plist[Loop];
        if (length(found)>3) and (fund[1] = '[') AND (fund[2] = 'M') AND (fund[3] = 'G') AND (fund[4] = ']') then //achte auf die änderung und die stellung
[...]

<HTH>
theromi Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 22



BeitragVerfasst: So 11.02.07 14:55 
Danke Grenzgaenger! Hätte ich auch drauf kommen können...

user profile iconMarco D. hat folgendes geschrieben:
BTW: Warum arbeitest du nicht mit copy?

Wie meinen? Sorry, bin Anfänger ;)
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: So 11.02.07 14:57 
Kannst auch einfach mit copy die ersten 4 Zeichen extrahieren und nachschauen, ob diese = '[MG]' sind. Such mal in der Hilfe nach 'Copy'. ;)

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
GTA-Place
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
EE-Regisseur
Beiträge: 5248
Erhaltene Danke: 2

WIN XP, IE 7, FF 2.0
Delphi 7, Lazarus
BeitragVerfasst: So 11.02.07 14:58 
ausblenden Delphi-Quelltext
1:
if Copy(Fund, 1, 4) = '[MG]' then					


oder besser:

ausblenden Delphi-Quelltext
1:
if Pos('[MG]', Fund) = 1 then					

_________________
"Wer Ego-Shooter Killerspiele nennt, muss konsequenterweise jeden Horrorstreifen als Killerfilm bezeichnen." (Zeit.de)