Autor Beitrag
Heiko
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3169
Erhaltene Danke: 11



BeitragVerfasst: Di 31.05.05 11:17 
Hast du auch festgelegt wie groß das array ist (mit Setlength)?
mwi Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 53

derzeit, win95 (usb version) win xp (prof) und suse 9.2
delphi 4 und 5 (prof)
BeitragVerfasst: Di 31.05.05 11:36 
sorry, mein fehler, hab ich vergessen...
funtzt leider trotzfem net
hier nochmal der veränderte code:
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:
begin
  pfad:=ExtractFilePath(ParamStr(0))+'prelint_long.txt'; //aktuelles Verzeichniss
//versuch, datei aus dem aktuellen verzeichniss zu öffnen
  AssignFile(f,pfad);
  {$I-} Reset(f); {$I+} //"Fehlermeldungsfänger"
//überprüfung, ob datei vorhanden

  if IOResult <>0 then
     begin
       showmessage('Fehler...');
       Exit
     end
  else
//zeilenweises auslesen
    begin
       while not eof(f) do
       begin
         readln(f,zeile);
          if zeile <>'' then
          begin
            inc(n);
            inc(m);
            setlength(a,m);
            a[m]:=zeile;
          end;

          if (zeile='') and (n>1) then n:=0;
          if (zeile='') and (n=1) then
          begin
            n:=0;
            a[m]:='';
            m:=m-1;
          end;

        end;
     end;
     auslesen(m,a);
    end;
Heiko
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3169
Erhaltene Danke: 11



BeitragVerfasst: Di 31.05.05 11:38 
Kannst du mal wider die Variablendeklaration hinzufügen? Ist einfacher, wenn man alles mit einem mal lesen kann :wink: .
mwi Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 53

derzeit, win95 (usb version) win xp (prof) und suse 9.2
delphi 4 und 5 (prof)
BeitragVerfasst: Di 31.05.05 11:41 
da ist sie schon
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
var
     f: textfile;
     a: array of string;
     zeile,pfad: string;
     m,n: integer;
Heiko
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3169
Erhaltene Danke: 11



BeitragVerfasst: Di 31.05.05 12:15 
Wie groß ist m? Du definierst für diese Variable keinen Ausgangswert. Damit ist das raay nicht definiert groß.
mwi Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 53

derzeit, win95 (usb version) win xp (prof) und suse 9.2
delphi 4 und 5 (prof)
BeitragVerfasst: Di 31.05.05 12:32 
ja, hab ich auch schon gemerkt:
hab dann am anfang der procedure m und n auf null gesetzt.
in der schleife wird ja dann m um eins hochgezählt und danach kommt der SetLength befehl.
ändert leider nichts an der funktiontüchtigkeit des progs :(

ausserdem hab ich die zuweisung bei den if abfragen geändert (bei if n=1 bzw. n>1 waren die then zweige vertauscht)
Heiko
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3169
Erhaltene Danke: 11



BeitragVerfasst: Di 31.05.05 12:38 
Wenn m zum Anfang 0 ist, muss Stelength so aussehen:

ausblenden Delphi-Quelltext
1:
setlength(a,m+1);					
mwi Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 53

derzeit, win95 (usb version) win xp (prof) und suse 9.2
delphi 4 und 5 (prof)
BeitragVerfasst: Di 31.05.05 12:44 
danke erstmal, das prog läuft jetzt erstmal wieder. aber die ausgabe ist nicht (sagen wir mal) wunschgemäß...
die einzeler nimmt das prog auf jeden fall raus. aber ein paar zweizeiler werden unvollständig dargestellt.
hab ich noch nen logischen fehler im prog?
Heiko
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3169
Erhaltene Danke: 11



BeitragVerfasst: Di 31.05.05 12:48 
user profile iconmwi hat folgendes geschrieben:
aber ein paar zweizeiler werden unvollständig dargestellt.


Wie meinst du das?
mwi Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 53

derzeit, win95 (usb version) win xp (prof) und suse 9.2
delphi 4 und 5 (prof)
BeitragVerfasst: Di 31.05.05 12:54 
wenn wir unser abc beispiel nehmen, sieht das in etwa so aus:

Textdokument:
a, b, c
d, e, f

g, h, i

j, k, l
m, n, o

Ausgabe des Progs:
a, b, c
m, n, o

naja, einige sachen werden wieder korrekt dargestellt. andere aber leider nach diesem beispiel.
Heiko
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3169
Erhaltene Danke: 11



BeitragVerfasst: Di 31.05.05 12:59 
Woher nimmst du eigentlich immer den Zeilenumbruch beim array?
mwi Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 53

derzeit, win95 (usb version) win xp (prof) und suse 9.2
delphi 4 und 5 (prof)
BeitragVerfasst: Di 31.05.05 13:06 
ich weis jetzt leider nicht genau, was du meinst.
aber ich lese die zeilen doch immer aus.
und jede zeile kommt doch vorsetzlich mal in ein eigenes arrayfeld.
danch wird der ganze spaß in einem stringgrid ausgelesen...

so entstehen bei mir zeilenumbrüche, oder was meinst du jetzt speziell???
Heiko
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3169
Erhaltene Danke: 11



BeitragVerfasst: Di 31.05.05 13:12 
Sry, ich hatte gerade einen Denkfehler als ich es gelesen hatte. Versuch es mal mit folgendem Quelltext:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
while not eof(f) do
 begin
  readln(f,zeile);
  if not(zeile='') then
   begin
    setlength(a, High(a)+2);
    a[High(a)]:=zeile
   end
 end;


Müsste funktionieren so wie du es haben willst, falls ich nicht gerade einen Denkfehler wieder habe :wink: .
mwi Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 53

derzeit, win95 (usb version) win xp (prof) und suse 9.2
delphi 4 und 5 (prof)
BeitragVerfasst: Di 31.05.05 13:24 
ich möchte dich ja nicht verärgern, aber meine tabelle bleibt leer, wenn ich deinen code nutze
Heiko
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3169
Erhaltene Danke: 11



BeitragVerfasst: Di 31.05.05 13:27 
Poste mal dein Programm. Mit Bsp. Textdatei und das wie es ausgegeben werden soll.
mwi Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 53

derzeit, win95 (usb version) win xp (prof) und suse 9.2
delphi 4 und 5 (prof)
BeitragVerfasst: Di 31.05.05 13:38 
hier isses.
ach ja ich verwende derzeit delphi 5 prof (falls es für dich jetzt wichtig ist)
Einloggen, um Attachments anzusehen!
mwi Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 53

derzeit, win95 (usb version) win xp (prof) und suse 9.2
delphi 4 und 5 (prof)
BeitragVerfasst: Di 31.05.05 14:30 
so ich habs jetzt.

steinigt mich virtuell oder auch nicht. aber mein letzter code war richtig.
nur das dig mit den beiden if abfragen hätte ich zuerst nicht für falsch erklären und daraufhin ändern dürfen.
root_at_localhost
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 191



BeitragVerfasst: Do 02.06.05 21:47 
bei dynamischen arrays musst du vor dem einfügen der werte die größe des Arrays festlegen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
var
  MyArray : Array of string;
begin
  SetLength(MyArray, 5); // MyArray hat jetzt die Länge 5, d.h. die Indizes MyArray[0] bis MyArray[4]
end;


Du kannst z.B. das Array mit SetLength(MyArray, 0); leeren und mit SetLength(MyArray, Length(MyArray) + 1); um jeweils einen Eintrag vergrößern.
Heiko
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3169
Erhaltene Danke: 11



BeitragVerfasst: Fr 03.06.05 08:34 
Das haben ich bereits gesagt!
deccer
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 57



BeitragVerfasst: Fr 03.06.05 08:47 
mmmh kA obs von belang ist, aber warum benutzt du/ihr eigentlich keine stringlist, anstelle des array of string?
</dooffrag>

_________________
I <3 PeRLe