Autor Beitrag
Seby-Deluxe
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 26

Win XP
7 Enterprise
BeitragVerfasst: Di 15.07.03 19:39 
Hallo,

Ich habe mal ne Frage! Ich wollte mal wissen wie ich ein Array in einer Datei Speichern kann! Und wie ich z.b ein Array Sortieren kann! kann mir da einer nen Tipp geben ?

thx
grayfox
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 800

win98, winXP
D4 Standard; D6 Personal
BeitragVerfasst: Di 15.07.03 20:31 
hallo seby!

zu deinem problem findest hier im forum bestimmt jede menge gute lösungsvorschläge. benutz einfach die suchfunktion, tippe Suche in: Delphi-Forum, Delphi-Library ARRAY ein und du wirst fündig...

du kannst ja auch mal --> hier nachlesen.

mfg, stefan
Seby-Deluxe Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 26

Win XP
7 Enterprise
BeitragVerfasst: Di 15.07.03 21:01 
ok ich guck mal nach
grayfox
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 800

win98, winXP
D4 Standard; D6 Personal
BeitragVerfasst: Di 15.07.03 21:09 
ok. tu das.
weil, wenn ich für dich nachguck, dann nutzt dir das auch net viel! ;)

mfg, stefan
Seby-Deluxe Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 26

Win XP
7 Enterprise
BeitragVerfasst: Di 15.07.03 21:20 
Titel: hmm
So habe geguckt habe aber unter den ersten 10 Seiten die angezeigt wurden nichts gefunden! Wäre echt cool wenn du mir mit worten sagen kannst wie das so gehen kann! oder nen link wo was steht !

wäre echt coool

big thx
cu
Klabautermann
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Veteran
Beiträge: 6366
Erhaltene Danke: 60

Windows 7, Ubuntu
Delphi 7 Prof.
BeitragVerfasst: Di 15.07.03 21:56 
Hallo,

gucke mal unter Suche in: Delphi-Forum, Delphi-Library TYPISIERTE DATEIEN und Suche in: Delphi-Forum, Delphi-Library BUBBLESORT.
Wenn du dann noch fragen hast, frage weiter, wir helfen gern.

Gruß
Klabautermann
Seby-Deluxe Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 26

Win XP
7 Enterprise
BeitragVerfasst: Do 17.07.03 20:37 
so das habe ich nun programmiert aber es geht net er sagt einen Fehler !



ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
VAR Datei:file of TSchueler;

procedure TForm1.SpeichernUnter1Click(Sender: TObject);
var i:integer;
begin
Savedialog1.Execute;
AssignFile(Datei,SaveDialog1.Filename);
Rewrite(Datei);
For i:=1 To 100 Do Write(Datei,Schueler[i]);
CloseFile(Datei);
end;

procedure TForm1.ffnen1Click(Sender: TObject);
var i:integer;
begin
OpenDialog1.Execute;
AssignFile(Datei,OpenDialog1.Filename);
Reset(Datei);
For i:= 1 To 100 Do Read(Datei,Schueler[i]);
CloseFile(Datei);
end;


aber er sagt mir bei der VAR einen fehler !


Zitat:
[Fehler] Noten.pas(157): Typ 'TSchueler' benötigt Finalization - nicht im Dateityp erlaubt



kann mir einer sagen was ich falsch gemacht habe?

Moderiert von user profile iconAya: Delphi und Quote-Tags hinzugefügt
Seby-Deluxe Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 26

Win XP
7 Enterprise
BeitragVerfasst: Do 17.07.03 21:06 
Bitte hilf mir einer, ist dringent muss das bis morgen fertig bekommen




vielen dank
grayfox
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 800

win98, winXP
D4 Standard; D6 Personal
BeitragVerfasst: Do 17.07.03 21:22 
hallo seby!
wie es aussieht, mag delphi deine definition von datei nicht
Zitat:

Typ 'TSchueler' benötigt Finalization - nicht im Dateityp erlaubt


wo hast denn die zeile hingeschrieben? in TForm?
kopier mal den ganzen code herein - so gross ist er ja nicht ;)

mfg, stefan


Zuletzt bearbeitet von grayfox am Do 17.07.03 21:39, insgesamt 1-mal bearbeitet
Seby-Deluxe Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 26

Win XP
7 Enterprise
BeitragVerfasst: Do 17.07.03 21:24 
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:
type
  TForm1 = class(TForm)
    Panel1: TPanel;
    Panel2: TPanel;
    PageControl1: TPageControl;
    TabSheet1: TTabSheet;
    TabSheet2: TTabSheet;
    StringGrid1: TStringGrid;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Button4: TButton;
    Button5: TButton;
    Button6: TButton;
    Button7: TButton;
    Button8: TButton;
    Edit19: TEdit;
    MainMenu1: TMainMenu;
    Datei1: TMenuItem;
    ffnen1: TMenuItem;
    Speichern1: TMenuItem;
    SpeichernUnter1: TMenuItem;
    SaveDialog1: TSaveDialog;
    Button9: TButton;
... einiges mehr !


  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

Type
  TSchueler = Record
  Name:Array[0..20]of Char;
  Vorname:Array[0..20]of  Char;
  MA:Integer;
  DE:Integer;
  EN:Integer;
  PAT:Integer;
  PRO:Integer;
  BSN:Integer;
  SWA:Integer;
  RS:Integer;
  DB:Integer;
  EP:Integer;
  Tue:Integer;
  WW:Integer;
  PH:Integer;
  PK:Integer;
  RE:Integer;
  SP:Integer;
  Schnitt:String;

end;

var
  Schueler:Array of TSchueler;
  datei : file of TSchueler;
  ID: longint;


implementation



meinst du das ?

mfg Seby

Moderiert von user profile iconAya: Delphi-Tags hinzugefügt
grayfox
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 800

win98, winXP
D4 Standard; D6 Personal
BeitragVerfasst: Do 17.07.03 21:44 
schon klar!

du liest oder schreibst deinen datenrecord in den ersten char des records und nicht in ein array

ausblenden Delphi-Quelltext
1:
For i:=1 To 100 Do Write(Datei,Schueler[i]);					


hier fehlt dir ein Array, zb
ausblenden Delphi-Quelltext
1:
2:
3:
4:
var
  Schueler:Array of TSchueler; 
  datei : file of TSchueler; 
    --> SchuelerListe: Array[1..100] of TSchueler;


das lesen & schreiben sieht dann so aus:
ausblenden Delphi-Quelltext
1:
For i:=1 To 100 Do Write(Datei,SchuelerListe[i]);					


mfg, stefan

oops: das kommt davon, wenn man gewohnt ist, dass TSchueler der type und Schueler die dazugehörige variable ist. man liest dann gar nimmer weiter ;)


Zuletzt bearbeitet von grayfox am Do 17.07.03 22:11, insgesamt 1-mal bearbeitet
Seby-Deluxe Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 26

Win XP
7 Enterprise
BeitragVerfasst: Do 17.07.03 21:47 
ok ich teste es
grayfox
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 800

win98, winXP
D4 Standard; D6 Personal
BeitragVerfasst: Do 17.07.03 21:48 
wenn dein programm dann läuft, setzt vor deinen code, den du hier ins forum gestellt hast
[.delphi.]
und nach der letzten zeile
[./delphi.] (ohne die punkte drin)
dann kann man es leichter lesen :)

mfg, stefan
Seby-Deluxe Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 26

Win XP
7 Enterprise
BeitragVerfasst: Do 17.07.03 21:50 
ne der sagt immer noch den fehler ! mist
ausblenden 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:
 
var
  Schueler:Array of TSchueler;
  datei : file of TSchueler;
  SchuelerListe: Array[1..100] of TSchueler;
  ID: longint;
implementation



procedure TForm1.SpeichernUnter1Click(Sender: TObject);
var i:integer;
begin
SaveDialog1.execute;
Assignfile(Datei,SaveDialog1.FileName);
Rewrite(Datei);
For i:=1 To 100 Do Write(Datei,SchuelerListe[i]);
Closefile(Datei);
end;

procedure TForm1.ffnen1Click(Sender: TObject);
var i:integer;
begin
OpenDialog1.Execute;
Assignfile(Datei,OpenDialog1.FileName);
Reset(Datei);
For i:=1 To 100 Do Read(Datei,SchuelerListe[i]);
CloseFile(Datei);
end;
grayfox
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 800

win98, winXP
D4 Standard; D6 Personal
BeitragVerfasst: Do 17.07.03 21:56 
weil grad zeit ist... ;)
deine konstruktion mit 1..100 ist aber auch sehr riskant, vor allem dann, wenn du weniger datensätze angelegt hat.
in diesem fall wärs günstiger, zuerst die anzahl der gespeicherten records festzustellen

ausblenden Delphi-Quelltext
1:
  anzahl:= FileSize(datei)					


liefert dir die anzahl der vorhandenen records im file
und danach würd ich erste die zählschleife von 1.. anzahl laufen lassen
aber darauf achten, dass anzahl nicht grösser als 100 wird. sonst in dein
array wieder zu klein geraten ;)

mfg, stefan
Seby-Deluxe Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 26

Win XP
7 Enterprise
BeitragVerfasst: Do 17.07.03 21:58 
ok kann ich auch die zahl einfach auf 1..50 setzten ? ich teste das mal aus !


vielen dank für deine hilfe
grayfox
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 800

win98, winXP
D4 Standard; D6 Personal
BeitragVerfasst: Do 17.07.03 21:59 
hoppala!
diese zeile kannst löschen, die haben wir jetzt doppelt ;)
ausblenden Delphi-Quelltext
1:
  -->  Schueler:Array of TSchueler;					


bitte um die fehlermeldung!
Seby-Deluxe Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 26

Win XP
7 Enterprise
BeitragVerfasst: Do 17.07.03 22:00 
ne ich kann machen was ich will der sagt mir immer noch bei
ausblenden Delphi-Quelltext
1:
datei : file of TSchueler;					


den fehler

[Fehler] Noten.pas(158): Typ 'TSchueler' benötigt Finalization - nicht im Dateityp erlaubt
grayfox
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 800

win98, winXP
D4 Standard; D6 Personal
BeitragVerfasst: Do 17.07.03 22:01 
ääähhh... hast überhaupt schon daten in einem file angelegt, welches du ausliest, bzw hast du auch 100 datensätze die du schreiben kannst?
Seby-Deluxe Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 26

Win XP
7 Enterprise
BeitragVerfasst: Do 17.07.03 22:03 
könntest du dir das Programm angucken ? wielleicht geht das besser !


[URL]wurde gelöscht [/URL]


Zuletzt bearbeitet von Seby-Deluxe am Do 17.07.03 22:25, insgesamt 1-mal bearbeitet