Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "Основная";
Текущий архив: 2005.09.18;
Скачать: [xml.tar.bz2];

Вниз

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;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.44 MB
Время: 0.016 c
14-1124977746
Digitman
2005-08-25 17:49
2005.09.18
Полтергейст ....


14-1124354453
Е-клмн
2005-08-18 12:40
2005.09.18
Коллекция цитат.


14-1124970763
ArtemESC
2005-08-25 15:52
2005.09.18
Современные форматы файловых систем


3-1123225440
Elvis
2005-08-05 11:04
2005.09.18
CheckBox в DBGrid


2-1123573788
rolex
2005-08-09 11:49
2005.09.18
В событии Form1 onShow пишу Form2.ShowModal, но Form1 не показыва





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский