Тема: Словарь
Показать сообщение отдельно
  #10  
Старый 25.09.2012, 19:26
Аватар для UnrealFire
UnrealFire UnrealFire вне форума
Новичок
 
Регистрация: 28.08.2012
Сообщения: 66
Версия Delphi: Delphi 7
Репутация: 10
По умолчанию

Код:
unit dict1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Grids, StdCtrls, Buttons;

type
  TMainForm = class(TForm)
    LogoLabel: TLabel;
    ScrollBox: TScrollBox;
    MainLabel: TLabel;
    SpeedButton1: TSpeedButton;
    Edit1: TEdit;
    procedure SpeedButton1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var

  MainForm: TMainForm;
  db:file of string[100];
  Li:String;

implementation

{$R *.dfm}



procedure TMainForm.SpeedButton1Click(Sender: TObject);
var
  fs: TFileStream;
  s: string;
{var str:string[100];
begin
  AssignFile(db,'db.txt');
  Rewrite(db);
  str:=str + #13 + edit1.Text;
  Write(db,str);
  Closefile(db);
  Memo1.lines.loadfromfile('db.txt'); //пишет (т.н. она заносится в фаил) какую-то калималю вместо слов.

end;}

{var stringList:TStringList;
begin
  stringList:=TStringList.Create;
  stringList.Add(Edit1.Text);
  stringList.SaveToFile('db.txt');
  stringList.free;
  Memo1.lines.loadfromfile('db.txt');}

begin
  if FileExists('db.txt') then
    fs := TFileStream.Create('db.txt', fmOpenWrite or fmShareDenyWrite)
  else
    fs := TFileStream.Create('db.txt', fmCreate);

  try
    s := Edit1.Text + #13#10;
    fs.WriteBuffer(Pointer(s)^, Length(s));
  finally
    fs.Free;
  end;
  MainLabel.Caption:=s;
end;

end.
вот код. пишет не по строкам а заменой. Где я ошибся?
Ответить с цитированием