lineoffset and regular expression ?

Jan Decroos jan.decroos at groepvanroey.be
Tue Mar 30 10:19:14 EST 2004


"thierry Douez" <douez at wanadoo.fr>

>Hi all,
>
>trying to understand the best way to deal with a lot of text
>in revolution, i found this problem :
>
>i'm using :
>	 put lineoffset("String2Find", text2lookAt, skippedLines ) into idx
>
>It works perfectly except that i need to do a second time :
>
>	if Offset("String2Find", line idx of text2lookAt ) is not 1 then ... Wrong
>place !
>
>How can I find the "String2Find" only at the beginning of a line ?
>
>I would prefer using lineoffset() for the next of the algorithm.
>
>Regards, thierry


If you work with Offset in stead of lineOffset the frist time, you get only
those lines starting with "String2Find" :
(in the repeat, 'idx' is the line number so you can use it for the next of your
algorithm)

on mouseUp
  -- initializing part
  put "Xabc"&CR&"abcY"&CR&"XabcY" into text2lookAt
  repeat 2
    put text2lookAt&CR&text2lookAt into text2lookAt
  end repeat
  put "abc" into String2Find
  
  
  put length(String2Find) into lLen
  put 0 into skippedChars
  repeat
    -- emergency stop, only during development
    if the optionKey = down then exit repeat  
    
    put offset(CR&String2Find, CR&text2lookAt, skippedChars) into lFoundPos
    if lFoundPos = 0 then exit repeat
    put the number of lines of (char 1 to skippedChars+lFoundPos of
text2lookAt) into idx
    -- 
    answer idx
    --
    add lFoundPos+lLen to skippedChars
  end repeat
end mouseUp

regards,
Jan



More information about the use-livecode mailing list