Autor Beitrag
bgeissl
Hält's aus hier
Beiträge: 7

WIN 2000
D6 Pers
BeitragVerfasst: Mi 16.02.05 15:17 
Hallo,

ich bin blutiger Anfänger und sitze schon den ganzen Tag an der Funktion 'ExtractStrings'. Sie wird ums verrecken nicht ausgeführt. Ich weis aber beim besten Willen nicht wo der Fehler liegen soll. Hat hier jemand eine Idee? Ich könnte die Funktion sicher schnell selber machen, aber wozu, wenn es sie schon gibt.

Gruß
Boris

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:
procedure ReadCSVBatch(Seperator:char;strFile:string);
var
  feedBack:word;
  cRow:integer;
  thisDir:string;
  mybatch:text;
  strLine:string;
  strList:TStrings;
  nStrings:integer;
  chrLine:pchar;
begin
  thisDir := ExtractFilePath(ParamStr(0));
  meldung_initialisieren(frmMain.memo1.lines);
  meldung.add('Application directory is ''' + thisDir + '''');
  meldung.add('Current batch is ''' + strFile + '''');
  assignfile(mybatch, strfile);
  {$I-}
  reset(mybatch);
  {$I+}

  if IOresult = 0 then begin
     while not eof(mybatch) do begin
       readln(mybatch,strLine);

       chrline:=pchar(strline);
       //Diese Funktion gibt immer 0 zurück und strList bleibt immer nil
       //chrLine ist soetwas wie 'VU;1955A;2345'
       nStrings:=ExtractStrings([';'], [' '], chrLine, strList);

     end;
     closefile(mybatch);
  end;
StefanH
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1144

Win XP
D5 Standard, D7 Pers, D2005 Pers
BeitragVerfasst: Mi 16.02.05 15:21 
du musst die Liste noch erstellen... also via
ausblenden Delphi-Quelltext
1:
strList:= TStringList.Create;					

und natürlich zum Schluss wieder freigeben. :D

_________________
"Als es noch keine Computer gab, war das Programmieren noch relativ einfach."(Edsger W. Dijkstra)
"Ich bin nicht von Sinnen, sondern ich rede wahre und vernünftige Worte." (Paulus)
AXMD
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 4006
Erhaltene Danke: 7

Windows 10 64 bit
C# (Visual Studio 2019 Express)
BeitragVerfasst: Mi 16.02.05 15:21 
Wie wär's, wenn du strList initialisieren würdest ;)

ausblenden Delphi-Quelltext
1:
strList := TStrings.Create;					


//EDIT: :x zu langsam

AXMD
Sprint
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 849



BeitragVerfasst: Mi 16.02.05 15:23 
Hallo?

TStrings ist eine abstrakte Klasse. Also nicht benutzen. Sondern TStringList.

_________________
Ciao, Sprint.
raziel
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2453

Arch Linux
JS (WebStorm), C#, C++/CLI, C++ (VS2013)
BeitragVerfasst: Mi 16.02.05 15:24 
Der Fehler liegt bei der Deklaration von strList:
Zunächst einmal sollte die Deklaration so aussehen:
  strList: TStringList;TStrings ist nämlich eine abstrakte Oberklasse für z.B. TStringList und man sollte daher besser TStringList verwenden ;)

Außerdem muss strList erst erzeugt werden:
ausblenden Delphi-Quelltext
1:
  strList := TStringList.Create;					

Und auch auf keinen Fall vergessen strList wieder freizugeben:
ausblenden Delphi-Quelltext
1:
  strList.Free;					



Gruß,
raziel

//hehe, naja, zumindest eine nette zusammenfassung ;)

_________________
JSXGraph
StefanH
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1144

Win XP
D5 Standard, D7 Pers, D2005 Pers
BeitragVerfasst: Mi 16.02.05 15:27 
Sprint hat folgendes geschrieben:
Hallo?

TStrings ist eine abstrakte Klasse. Also nicht benutzen. Sondern TStringList.


:oops: den Fehler hatte ich ganz übersehen...

_________________
"Als es noch keine Computer gab, war das Programmieren noch relativ einfach."(Edsger W. Dijkstra)
"Ich bin nicht von Sinnen, sondern ich rede wahre und vernünftige Worte." (Paulus)
bgeissl Threadstarter
Hält's aus hier
Beiträge: 7

WIN 2000
D6 Pers
BeitragVerfasst: Mi 16.02.05 15:49 
Titel: Vielen Dank! Hat funktioniert! Freibier für alle!!!! o. T.
Vielen Dank! Hat funktioniert! Freibier für alle!!!! o. T.
AXMD
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 4006
Erhaltene Danke: 7

Windows 10 64 bit
C# (Visual Studio 2019 Express)
BeitragVerfasst: Mi 16.02.05 15:58 
Titel: Re: Vielen Dank! Hat funktioniert! Freibier für alle!!!! o.
bgeissl hat folgendes geschrieben:
Freibier für alle!!!! o. T.


Ich nehm dich beim Wort :mrgreen:

AXMD