Offset with 'charstoskip' doesn't work? [was RunRev vsRealBasic (Richard Gaskin)]

Alex Tweedly alex at tweedly.net
Fri Jan 21 11:05:14 EST 2005


Michael D Mays wrote:

> I thought I would see if I could solve the RB/Rev/SC challenge and 
> tried this as a first attempt:
>
> on mouseUp
>   put fld 1 into sFld
>   put fld 2 into tFld
>   put "" into fld 3
>   -- put 0 into it --*1
>   put zero into t --*2
>   repeat with i= 1 to the number of lines in tFld
>     repeat
>       -- get offset(line i of tFld,sfld,it) --*1
>       get offset(line i of tFld,sfld,t) --*2
>       put it into t --*2
>       if it is zero then exit repeat
>       put line i of tFld&&i&&it&return after fld 3
>     end repeat
>   end repeat
> end mouseUp
>
> but what happens is along the way it finds a search string in question 
> at char 246674 and then finds it again at 250675 and then finds it 
> again at 246674 then at 250675 then at 246674 then at 250675 ...
>
> Is offset not working or am I not?
>
It's you :-)
When you do the second search, t already contains an 'skip' value; the 
result from the offset search is relative to that.
So instead of
  put it into t
you should do
  add it to t

-- Alex.



-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.300 / Virus Database: 265.7.1 - Release Date: 19/01/2005



More information about the use-livecode mailing list