Autor Beitrag
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:14 
versteh ich nicht. bei mir kompiliert er anstandslos drüber.
das lesen & schreiben kann ich leider nicht testen, aber das sollte klappen.

mfg, stefan

ich darf es nicht herunterladen - die seiten wurde aus irgendeinem grund gesperrt *grml*
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:16 
ach jo das war der admin !
son mist
Brueggendiek
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 304

Win 98, Win98SE, Win XP Home
D5 Std
BeitragVerfasst: Do 17.07.03 23:14 
Hallo Seby!

Dein Record enthält einen STRING! Die können nicht in typisierte Dateien geschrieben werden, da sie normalerweise Ansistrings und damit Pointer sind. Schreibe da "String [10]" oder so hin (wieviele Zeichen Du halt brauchst, maximal 255), dann klappt's auch mit dem Nachbarn!

Ach ja - ein Packed Record wäre auch nicht schlecht, da sonst die Speicherausrichtung Platz kostet und in späteren Delphi-Versionen anders gehandhabt werden könnte - Folge: die Datei läßt sich nicht mehr einlesen!

Gruß

Dietmar Brüggendiek
Tino
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Veteran
Beiträge: 9839
Erhaltene Danke: 45

Windows 8.1
Delphi XE4
BeitragVerfasst: Fr 18.07.03 08:24 
Seby-Deluxe hat folgendes geschrieben:
ach jo das war der admin !
son mist

Was soll der Admin gemacht haben?

Gruß
Tino
maximus
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 896

Win XP, Suse 8.1
Delphi 4/7/8 alles prof
BeitragVerfasst: Fr 18.07.03 10:15 
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:
...
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; // <- hier ist das problem ...der string ist nicht finalisiert  -> Schnitt:String[255] sollte helfen

end;


Und unbedingt packed records verwenden, wenn du mit dateien arbeitest :wink: sonst kriegste daten-salat.

viel glück

// EDIT:

OH... da war ja noch ne zweite seite :oops:

_________________
mfg.
mâximôv
Seby-Deluxe Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 26

Win XP
7 Enterprise
BeitragVerfasst: Fr 18.07.03 15:52 
ok sas mit dem Speichern geh noch net 100% tig aber gucken das klappt schon hoffen ich
Seby-Deluxe Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 26

Win XP
7 Enterprise
BeitragVerfasst: Fr 18.07.03 18:47 
So mein Speichern und Öffen geht immer noch net ! kann einer von euch einen fehler sehen ???

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:
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[255];

end;

var
  Schueler:Array of TSchueler;
  temp_array_schueler: array [0..0] of TSchueler;
  Datei:file of TSchueler;
  ID: longint;

implementation



procedure TForm1.SpeichernUnter1Click(Sender: TObject);
var i:integer;
begin
//geht auch noch net 100%tig
SaveDialog1.Execute;
Assignfile(Datei,SaveDialog1.FileName);
Rewrite(Datei);
For i:=1 To High(Schueler) Do Write(Datei,Schueler[i]);
Closefile(Datei);
end;

procedure TForm1.ffnen1Click(Sender: TObject);
var i:integer;
begin
// Geht noch nicht
OpenDialog1.Execute;
Assignfile(Datei,OpenDialog1.FileName);
Reset(Datei);
For i:=1 To high(Schueler) Do Read(Datei,Schueler[i]);
CloseFile(Datei);
end;
maximus
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 896

Win XP, Suse 8.1
Delphi 4/7/8 alles prof
BeitragVerfasst: Sa 19.07.03 01:10 
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 
  TSchueler = packed Record // -> wie gesagt WICHTIG! Warum muss man sich eigentlich immer wiedrholen? ;)
  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[255]; 

end; 

var 
  Schueler:Array of TSchueler; 
  temp_array_schueler: array [0..0] of TSchueler; // wo is hier der sinn?
  Datei:file of TSchueler; 
  ID: longint; 

implementation 



procedure TForm1.SpeichernUnter1Click(Sender: TObject); 
var i:integer; 
begin 
//geht auch noch net 100%tig 
  if SaveDialog1.Execute then // -> bei 'abbrechen' gehts hier nicht weiter
  try // resourcen-schutz 
    Assignfile(Datei,SaveDialog1.FileName); 
    Rewrite(Datei); 
    For i:= low(Schueler)To High(Schueler) // indizes fangen IMMER bei 0 an, bzw 'low' (ausnahmen bestetigen die regel)
    Do Write(Datei,Schueler[i]); 
  finally
    Closefile(Datei); 
  end;
end; 

procedure TForm1.ffnen1Click(Sender: TObject); 
var i:integer; 
begin 
  if OpenDialog1.Execute then // dito
  try  
    Assignfile(Datei,OpenDialog1.FileName); 
    Reset(Datei); 
    setLength(Schueler,0); // länge zurück setzen!
    while not EoF(Datei)  do // EoF = END of FILE
    begin
      i := length(Schueler)
      setLength(Schueler,i+1);
      Read(Datei,Schueler[i]); 
     end;
  finally
     CloseFile(Datei); 
   end;
end;


Hoffe leuchtet ein -> immer schön absichern...sonst macht coden keinen spass, da man in den spagetties erstickt :wink:

_________________
mfg.
mâximôv
Seby-Deluxe Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 26

Win XP
7 Enterprise
BeitragVerfasst: Sa 19.07.03 07:37 
Vielen dank ich danke dir !


es funkt !


thx