<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=Windows-1252">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.0.6396.0">
<TITLE>wordoffset bug?</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/plain format -->
<P><FONT SIZE=2>Hi all,<BR>
I wrote a script that searches a piece of text in all scripts of my project.<BR>
I use a repeat loop to go through all stack scripts, button scripts, etc.<BR>
The script inside the repeat loop looks something like this:<BR>
(wholeMatches is set to true; fndTxt is the text to find)<BR>
<BR>
...<BR>
put the script of stack stackName into searchScript<BR>
put wordOffset (fndTxt, searchScript) into k<BR>
...<BR>
<BR>
Much to my surprise, the script sometimes returned k > 0, whereas the word fndTxt was not in searchScript. I changed the script as follows:<BR>
<BR>
...<BR>
put the script of stack stackName into searchScript<BR>
put wordOffset (fndTxt, searchScript) into k<BR>
put the number of words of searchScript into n<BR>
...<BR>
<BR>
Even to my greater surprise, the number k exceeded the number n.<BR>
My next change was:<BR>
<BR>
...<BR>
delete local searchScript<BR>
put the script of stack stackName into searchScript<BR>
put wordOffset (fndTxt, searchScript) into k<BR>
put the number of words of searchScript into n<BR>
...<BR>
<BR>
Now the script behaved as expected.<BR>
The same behavior occurred with 'if fndTxt is among the words of searchScript'.<BR>
Apparently the search exceeds in some way or another the actual length of searchScript, maybe caused by the fact that in earlier loops different values (other script texts) were assigned to searchScript.<BR>
Although the error occurs always in the same ('search')scripts of my stack, I'm not able to reproduce the error in a simple script; apparently it depends on the earlier values of searchScript in the loop.<BR>
Any ideas?<BR>
<BR>
Wil Dijkstra<BR>
<BR>
</FONT>
</P>
</BODY>
</HTML>