lineoffset and regular expression ?

thierry Douez douez at wanadoo.fr
Wed Mar 31 14:49:39 EST 2004


Hi,

in fact, one can use :
put lineoffset( CR & "String2Find", text2lookAt, skippedLines ) into idx

it works well !

but the problem i found then is the time expanding when the text2lookAt
starts to grow... did the test with 900 Kb of text...

So, instead of using skippedLines, i delete the line 1 to the 'idx' line
of the text2lookAt; get better result but still, not very fast. it seems
that the delete build in function has a strange behavior; very fast at
the beginning of the text and more and more we go to the end of the text,
increase drastically in time ( delete more or less the same size ).

Any Comments on this ?

regards, thierry

  | >	 put lineoffset("String2Find", text2lookAt, skippedLines ) into idx
  | >	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 ?
  | >
  | If you work with Offset in stead of lineOffset the first 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
  |     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
  |     
  |     SaveIndex( idx ) -- PrivateFunction to store all indexes
  |    
  |     add lFoundPos+lLen to skippedChars
  |   end repeat
  | end mouseUp
  | 
  | regards, Jan



More information about the use-livecode mailing list