Autor Beitrag
masteroffinalfantasy
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 82

Win XP
Delphi 2005 Architect
BeitragVerfasst: Mi 28.06.06 07:21 
Hoi DF :)

ich bin gerade dabei, eine CSV Datei in ein zweidimensionales Array einzulesen. Wenn ich die Datei öffne und dann auslesen will, kommt irgendwie ein Externer Exceptionfehler. Kann mir da jemand sagen wo das Problem ist?

Die Datei ist nicht in Benutzung.

Falls es hilft:

Hier der Code des Imports:
ausblenden volle Höhe 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:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
function Explode(const Separator, S: string; Limit: Integer = 0): TStringDynArray;
var
  SepLen: Integer;
  F, P: PChar;
  ALen, Index: Integer;
begin
  SetLength(Result, 0);
  if (S = '') or (Limit < 0) then Exit;
  if Separator = '' then
  begin
    SetLength(Result, 1);
    Result[0] := S;
    Exit;
  end;
  SepLen := Length(Separator);
  ALen := Limit;
  SetLength(Result, ALen);

  Index := 0;
  P := PChar(S);
  while P^ <> #0 do
  begin
    F := P;
    P := StrPos(P, PChar(Separator));
    if (P = nil) or ((Limit > 0) and (Index = Limit - 1)) then P := StrEnd(F);
    if Index >= ALen then
    begin
      Inc(ALen, 5); // mehrere auf einmal um schneller arbeiten zu können
      SetLength(Result, ALen);
    end;
    SetString(Result[Index], F, P - F);
    Inc(Index);
    if P^ <> #0 then Inc(P, SepLen);
  end;
  if Index < ALen then SetLength(Result, Index); // wirkliche Länge festlegen
end;

procedure TForm7.Button1Click(Sender: TObject);
 var 
Spiel:TStringDynArray;
Mannschaft:Array[1..50,1..35] of string;
x,i,k:integer;
p,s,t:string;
f:Textfile;

begin

 OpenDialog1.Execute;
 p:=OpenDialog1.FileName;
 assignfile(f,p);
 reset(f);
 i:=0;
   while not eof(f) do 
    begin
     i:=i+1;
     t:='';
     readln(f,s);
     spiel:=explode(';',s);
     k:=length(spiel);
     for x:=1 to k do 
      begin
       Mannschaft[i,x]:=spiel[x];
       t:=t+' '+spiel[x];
     end;
   end;
 showmessage(Mannschaft[2,1]);
end;


Zuletzt bearbeitet von masteroffinalfantasy am Mi 28.06.06 08:13, insgesamt 1-mal bearbeitet
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mi 28.06.06 08:03 
Moin!

Schonmal was von "Einrücken" gehört, oder das Zauberwort Suche bei Google STYLEGUIDE? :roll: Da kriegt man ja Augenkrebs... ;)

Ansonsten: Suche in: Delphi-Forum, Delphi-Library CSV IMPORT Sochmal geschaut, ob das nicht eventuell ein bereits bekanntes Problem ist, CSVs zu Importieren? Dann könntest du ja da den Code abschreiben... :D

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
masteroffinalfantasy Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 82

Win XP
Delphi 2005 Architect
BeitragVerfasst: Mi 28.06.06 08:14 
hallo narses

jo mit dem Augenkrebs geb ich dir Recht ;) habs mal etwas eingerückt^^

desweiteren hatte ich schon nach csv import gesucht und bin nicht auf mein Problem gestossen
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mi 28.06.06 08:26 
Moin!

@aktuelles Problem: fangen dyn. Arrays nicht bei 0 an? :gruebel:

@Suchfähigkeiten: Ich bin mir ganz sicher, dass es eine Menge Beiträge dazu gibt (weil ich selbst schon was dazu geschrieben habe); du solltest in Erwägung ziehen, dass der vorhandene Code nicht wörtlich zu deinem Problem passt, es wird also nötig sein, das anzupassen.

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
masteroffinalfantasy Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 82

Win XP
Delphi 2005 Architect
BeitragVerfasst: Mi 28.06.06 09:09 
das Problem liegt wiegesagt darin, dass es eine externe Exception ist und ich nicht weiß, wie ich das behebe, bzw. wo überhaupt die ursache ist
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mi 28.06.06 10:04 
Moin!

Dann kopier doch mal den Text der Fehlermeldung und setz das mal hier rein. So kommen wir ja nicht weiter.

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
masteroffinalfantasy Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 82

Win XP
Delphi 2005 Architect
BeitragVerfasst: Mi 28.06.06 10:13 
---------------------------
Benachrichtigung über Debugger-Exception
---------------------------
Im Projekt Project1.exe ist eine Exception der Klasse EExternalException mit der Meldung 'Externe Exception 80000001' aufgetreten.
---------------------------
Anhalten Fortsetzen Hilfe
---------------------------
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mi 28.06.06 10:21 
Moin!

OK, mal mit dem Debugger durchsteppen und die fehlerauslösende Zeile bestimmen. Ganz offensichtlich erzeugt ja dein Programm diese Ausnahmebedingung, also wird auch eine Anweisung im Programm dafür verantwortlich sein.

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
masteroffinalfantasy Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 82

Win XP
Delphi 2005 Architect
BeitragVerfasst: Mi 28.06.06 10:33 
ach ich habs. Das x darf nur max k-1 sein, weil sonst der string schon zu Ende ist!

Kleine Nebenfrage :
wie war das nochmal mit dem zurücksetzen des Pfades ?
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mi 28.06.06 10:48 
Moin!

Zum einen: welcher Pfad? :gruebel:

zum anderen: neue Frage :arrow: neuer Thread! (Forumsregel! :mahn: ;))

cu
Narses

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