out how to preserve the value of a variable
cCount which I want to use in the following
code.
dString is like this -
3,1,2,1,3,3,3,3,3,2,2,1,3,1,2,2,1,1,3
Want to code to:
Get item 1 (3 in this case) and look for first
occurrence of either of the other two numbers
(1 and 2 in this case).
Item 2 is 1 so this cycle is done.
The next number to consider is item 3 (2) and
look for next 1 or 3. Item 4 is 1 so second cycle done.
Next number to consider is item 5 (3) so will look for 1 or 2.
Neither 1 nor 2 will be found by look1 so go to look2
and so on (up to look5 if necessary) which returns "Failed".
Most of this works but I haven't been able to figure out
a way to return vCount to the repeat loop in the mouseUp
handler so that the next item use is the one after the last
one found e.g. last found at item 10 so want to use
item 11 for next search.
Using a variable for the value of i and incrementing it works
while going down but on the way back (up) at the mouseUp
handler the value is lost for some reason.
Have tried using "return vCount" and a few other things
without success.
Code: Select all
pseudo-code...
----------------------
on mouseUp
put 1 into vCount
repeat with i = vCount to number of items in dString
get look1(vCount)
end repeat
end mouseUp
----------------------
function look1 vCount
if item vCount+1 of dString = item vCount of dString then
...
add 1 to vCount
exit look1
else
add 1 to vCount --- = 2
get look2(vCount)
exit look1
end if
end look1
---------------------
function look2 vCount
if item i + 2 of dString = item i of dString then
...do things
add 1 to vCount --- = 3
exit look2
else
add 1 to vCount
get look3(vCount)
exit look2
end if
end look2
---------------------
function look3 vCount
if item i + 3 of dString = item i of dString then
...do things
add 1 to vCount
exit look3
else
add 1 to vCount
get look4(vCount)
exit look3
end if
end look3
---------------------
function look4 vCount
if item i + 4 of dString = item i of dString then
...do things
add 1 to vCount
exit look4
else
add 1 to vCount
get look5(vCount)
exit look4
end if
end look4
---------------------
function look5 vCount
if item i + 5 of dString = item i of dString then
...do things
add 1 to vCount
exit look5
else
add 1 to vCount
exit look5
end if
end look5
Probably haven't explained this very well
but any ideas appreciated. Only other thing
to add is that the mysterious system variable "it"
seems to increment sometimes but haven't
tried using it since I don't know what its value
represents.