Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2005.09.18;
Скачать: CL | DM;

Вниз

ExtractWord   Найти похожие ветки 

 
Ed ©   (2005-08-26 22:13) [0]

В двух словах. Попали в руки исходники с Delphi4, где используется ExtractWord, я работаю на Delphi6, который такого не знает. Может появилось что-то новое? Чем его можно заменить?


 
Турист   (2005-08-26 22:40) [1]

Вариант из RxLib


type
 TCharSet = set of Char;

function WordPosition(const N: Integer; const S: string;
 const WordDelims: TCharSet): Integer;
var
 Count, I: Integer;
begin
 Count := 0;
 I := 1;
 Result := 0;
 while (I <= Length(S)) and (Count <> N) do begin
   { skip over delimiters }
   while (I <= Length(S)) and (S[I] in WordDelims) do Inc(I);
   { if we"re not beyond end of S, we"re at the start of a word }
   if I <= Length(S) then Inc(Count);
   { if not finished, find the end of the current word }
   if Count <> N then
     while (I <= Length(S)) and not (S[I] in WordDelims) do Inc(I)
   else Result := I;
 end;
end;

function ExtractWord(N: Integer; const S: string;
 const WordDelims: TCharSet): string;
var
 I: Integer;
 Len: Integer;
begin
 Len := 0;
 I := WordPosition(N, S, WordDelims);
 if I <> 0 then
   { find the end of the current word }
   while (I <= Length(S)) and not(S[I] in WordDelims) do begin
     { add the I"th character to result }
     Inc(Len);
     SetLength(Result, Len);
     Result[Len] := S[I];
     Inc(I);
   end;
 SetLength(Result, Len);
end;


 
Ed ©   (2005-08-27 20:39) [2]

Может есть что покороче, а то как-то несоразмеримо ExtractWord и этот код


 
begin...end ©   (2005-08-27 20:51) [3]

Удалено модератором



Страницы: 1 вся ветка

Текущий архив: 2005.09.18;
Скачать: CL | DM;

Наверх




Память: 0.47 MB
Время: 0.038 c
1-1125055272
rbbatoon89
2005-08-26 15:21
2005.09.18
"Красивый" набор компонентов


14-1125051879
DLLKos88
2005-08-26 14:24
2005.09.18
код для склеивания двух exe файлов???


14-1124526656
Веретенников
2005-08-20 12:30
2005.09.18
Оцифровка видио


14-1124525134
BagMaker
2005-08-20 12:05
2005.09.18
Как можно узнать, что компьютер подключен к интернету?


1-1125061067
Aleksandr.
2005-08-26 16:57
2005.09.18
С чем может быть связана показ меню не в той кодировке?