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

Michael D Mays michael.rr at mdmays.com
Fri Jan 21 11:50:46 EST 2005


On Jan 21, 2005, at 10:05 AM, Alex Tweedly wrote:

> 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.
>

Someday I will read the complete description in the documentation all 
by myself.:)
Thanks.

But what is the advantage of returning the offset from the last offset 
rather than the offset from beginning?

I think I do need to insert
   put zero into t
after the first repeat and before the second repeat.

Michael



More information about the use-livecode mailing list