
16.05.2009, 17:43
|
 |
Гуру
|
|
Регистрация: 09.03.2009
Адрес: На курорте, из окна вижу теплое Баренцево море. Бррр.
Сообщения: 4,723
Репутация: 52347
|
|
Вот вам готовый код. Что-то добренький я сегодня.
Код:
program Project1;
{$APPTYPE CONSOLE}
uses
SysUtils,Classes,StrUtils;
Const
KeyWordsCount = 2;
KeyWords: Array[1..KeyWordsCount] of String = ('begin','end');
Var
File1,File2: TextFile;
i,p: Integer;
s: String;
begin
AssignFile(File1, 'C:\Documents and Settings\All Users\Документы\tmssoftware\TAdvMemo Demos\uAddictSpellCheck.pas');
Reset(File1);
AssignFile(File2, 'c:\test.txt');
Rewrite(File2);
while not Eof(File1)
do begin
ReadLn(File1, s);
s := StringReplace(s,' ',' ',[rfReplaceAll]) + ' ';
for i := 1 to KeyWordsCount
do begin
p := PosEx(KeyWords[i], AnsiLowerCase(s), 1);
while p > 0
do begin
WriteLn(File2, KeyWords[i]);
p := PosEx(KeyWords[i], AnsiLowerCase(s), p+Length(KeyWords[i]));
end;
end;
end;
CloseFile(File2);
CloseFile(File1);
end.
__________________
Жизнь такова какова она есть и больше никакова.
Помогаю за спасибо.
|