Yoko

All sides of Injection
It is currently 2024-04-19 00:55:49

All times are UTC+02:00




Post new topic  Reply to topic  [ 5 posts ] 
Author Message
PostPosted: 2012-01-29 01:23:49 
Offline
User avatar

Joined: 2009-05-28 09:58:28
Posts: 2802
Location: Иваново
Code:
Sub GetWord( st, nom )
    ; (c) Edred
    ; Возвращает слово из строки str за номером num
    ; если такого слова нет - возвращаем ''
    ;
    ; Разделителем слов считаем пробел. Несколько пробелов подряд считаются за один.
    ; Функция сделана без рекурсии специально для считывания слов из сверхдлинных строк!
    ;
    VAR tmpst, i, dlin, kol = 0, start = 0
    dlin = len( st )
    For i=0 To dlin - 1
        If mid( st, i, 1 ) == ' ' OR i == dlin - 1 Then
            kol = kol + 1
            If kol == nom Then
                ; это первый пробел после нужного нам слова
                tmpst = mid( st, start, i - start )
                return tmpst
            Else
                While mid( st, i, 1 ) == ' '
                    i = i + 1
                Wend
                If kol == nom - 1 Then
                    start = i
                Endif
            Endif
        Endif
    Next
    tmpst = ''
    return tmpst
end sub


Заметил странность. Почему то не пропечатывает последний символ последнего в строке слова.
str = 'на улице было 20 градусов мороза'
GetWord( str, 4 ) = 20
GetWord( str, 2 ) = улице

НО
GetWord( str, 6 ) = мороз
а потерялось.
Это у меня так глючит или так и задумано? :cry:

_________________
Image
YokoInjection CodeSweeper
Ошибка "Unhandled exception in parser"
Стрелялка для олдов.


Top
   
PostPosted: 2012-01-29 02:02:35 
Offline
User avatar

Joined: 2009-05-28 09:58:28
Posts: 2802
Location: Иваново
Сам разобрался. :mrgreen:
Новый вариант процедуры вот там.

_________________
Image
YokoInjection CodeSweeper
Ошибка "Unhandled exception in parser"
Стрелялка для олдов.


Top
   
PostPosted: 2012-01-29 08:13:11 
Offline

Joined: 2005-02-08 18:39:50
Posts: 444
Location: Moscow
а для чего сам скрип-То? :oops:


Top
   
PostPosted: 2012-01-29 09:09:11 
Offline
User avatar

Joined: 2009-05-28 09:58:28
Posts: 2802
Location: Иваново
чтобы работать с текстом ;)

_________________
Image
YokoInjection CodeSweeper
Ошибка "Unhandled exception in parser"
Стрелялка для олдов.


Top
   
PostPosted: 2012-01-30 19:51:34 
Offline

Joined: 2005-02-08 18:39:50
Posts: 444
Location: Moscow
для бота рекламщика, например?
или оно наоборот - считывает?

диковенное писание :)


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 5 posts ] 

All times are UTC+02:00


Who is online

Users browsing this forum: No registered users and 45 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Limited