| 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:
 68:
 69:
 70:
 71:
 72:
 73:
 74:
 75:
 76:
 77:
 78:
 79:
 80:
 81:
 82:
 83:
 84:
 85:
 86:
 87:
 88:
 89:
 90:
 91:
 92:
 93:
 94:
 95:
 96:
 97:
 98:
 99:
 100:
 101:
 102:
 103:
 104:
 105:
 106:
 107:
 108:
 109:
 110:
 111:
 112:
 113:
 114:
 115:
 116:
 117:
 118:
 119:
 120:
 121:
 122:
 123:
 124:
 125:
 126:
 127:
 128:
 129:
 130:
 131:
 132:
 133:
 134:
 135:
 136:
 137:
 138:
 139:
 140:
 141:
 142:
 143:
 144:
 145:
 146:
 147:
 148:
 149:
 
 | unit Unit1;
 interface
 
 uses
 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
 Dialogs, StdCtrls;
 
 
 
 type
 TForm1 = class(TForm)
 ListBox1: TListBox;
 Button7: TButton;
 procedure Button7Click(Sender: TObject);
 private
 
 public
 
 end;
 
 var
 Form1: TForm1;
 
 implementation
 
 {$R *.dfm}
 type Tdaten=ansistring;
 
 const st_laenge=8;
 linebr=2;
 
 procedure datei_leeren(Filename:string);
 var fs: TFileStream;
 begin
 fs := TFileStream.Create(Filename, fmOpenReadWrite or fmShareDenyWrite);
 try
 fs.Size := 0;
 finally
 fs.Free;
 end;
 end;
 
 
 procedure InsertData(Filename:string; const P, Len: Int64; insert: Tdaten);
 const
 BufSize = $00010000;
 var
 Buf: PChar;
 N: Integer;
 Size, Z: Int64;
 fs:Tstream;
 begin
 fs := TFileStream.Create (Filename, fmopenreadwrite);
 GetMem(Buf, BufSize);
 try
 Z := 0;
 Size := fs.Size;
 repeat
 if (Size-Z)-P < BufSize then N := (Size-Z)-P else N := BufSize;
 fs.Position := Size-Z-N;
 fs.Read(Buf^, N);
 fs.Position := Size-Z-N+Len;
 fs.Write(Buf^, N);
 Inc(Z, N);
 until (Size-Z) = P;
 
 fs.Position:=p;
 if insert <> '' then
 fs.Write (insert[1], len);
 fs.Write(sLineBreak, Length(sLineBreak));
 
 finally
 FreeMem(Buf, BufSize);
 end;
 fs.Free;
 end;
 
 
 
 procedure SaveStringToFile (st_laenge1:word; Filename:string; SaveString: tdaten; npos:integer);
 var
 fs: TFileStream;
 begin
 fs := TFileStream.Create (Filename, fmopenreadwrite);
 try
 fs.Position:=npos;
 if SaveString <> '' then
 fs.Write (SaveString[1], st_laenge1);
 fs.Write(sLineBreak, Length(sLineBreak));
 finally
 fs.Free;
 end;
 end;
 
 
 procedure TForm1.Button7Click(Sender: TObject);
 var str:string;
 i,id1,n:cardinal;
 data:tdaten;
 y:byte;
 breite:word;
 begin
 datei_leeren(ExtractFilePath(Application.ExeName) + '1feld.dat');
 
 str:='Luftballon';
 
 breite:=1; n:=0;
 savestringtofile(breite,ExtractFilePath(Application.ExeName) + '1feld.dat',str,n);
 breite:=2; n:=3;   savestringtofile(breite,ExtractFilePath(Application.ExeName) + '1feld.dat',str,n);
 breite:=3; n:=7;   savestringtofile(breite,ExtractFilePath(Application.ExeName) + '1feld.dat',str,n);
 breite:=4; n:=12;   savestringtofile(breite,ExtractFilePath(Application.ExeName) + '1feld.dat',str,n);
 breite:=5; n:=18;   savestringtofile(breite,ExtractFilePath(Application.ExeName) + '1feld.dat',str,n);
 breite:=6; n:=25;   savestringtofile(breite,ExtractFilePath(Application.ExeName) + '1feld.dat',str,n);
 
 
 
 
 insertdata(ExtractFilePath(Application.ExeName) + '1feld.dat',3,4,'Mond');
 
 
 
 
 end;
 
 end.
 |