![]() |
|
|
|||||||
| Регистрация | << Правила форума >> | FAQ | Пользователи | Календарь | Поиск | Сообщения за сегодня | Все разделы прочитаны |
![]() |
|
|
Опции темы | Поиск в этой теме | Опции просмотра |
|
|
|
#1
|
||||
|
||||
|
Прошу помочь с одной програмкой. Мне надо было написать програмку которая бы считывала текст из одного файла (*.txt) и записывала этот текст в другой но в другом должен стоять на лимит(не более 60 символов в строке) и остальное содержимое должно переноситься на следующую строку не разрывая слов. У меня есть основа этой программы, но она не входящий в пределы текст просто удаляет. Прошу помочь, вот код
Код:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var i:integer;
files,files2:TextFile;
str,str2:string;
begin
str2:='';
if not FileExists('test.txt') then exit;
AssignFile(files,'test.txt');
Reset(files);
while not Eof(files) do
begin
ReadLn(files, str);
AssignFile(files2,'test2.txt');
Append(files2);
for i:=1 to length(str) do
begin
if i>60 then break;
if str[i]<>' ' then
str2:=str2+str[i] else
str2:=str2+' ';
end;
Writeln(files2,str2);
closefile(files2);
str2:='';
end;
closefile(files);
end;
end. |
|
#2
|
||||
|
||||
|
Код:
unit Unit1;
interface
uses
StdCtrls,
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms;
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
var
Memo: TMemo;
Memo2: TMemo;
begin
Memo:=TMemo.Create(Self);
Memo.Parent:=Self;
Memo.Font.Name:='Courier';
Memo.WordWrap:=True;
Canvas.Font.Assign(Memo.Font);
Memo.ClientWidth:=Canvas.TextWidth('Wg')*30+Canvas.TextWidth('W');
Memo.Lines.LoadFromFile('c:\Downloads\memo');
Memo2:=TMemo.Create(Self);
Memo2.Parent:=Self;
Memo2.Lines.Assign(Memo.Lines);
Memo2.Lines.SaveToFile('c:\Downloads\memo3');
Memo2.Free;
Memo.Free;
end;
end. |
|
#3
|
||||
|
||||
|
хм. но этот код не работает, программа не переносит текст(
|
|
#4
|
||||
|
||||
|
в Delphi 6 работает - ибо давно заметил такой баг за Memo
![]() |
|
#5
|
||||
|
||||
|
код в Д7 работает, но он не переносит слова он их разБивает
sry обписАлся ![]() Последний раз редактировалось friz, 01.11.2010 в 15:51. |
|
#6
|
||||
|
||||
|
чявой делает?
|