Oops, the word() functions reference should have been
If(word(-1,Y[i],".") == "txt"
negative values indicate to count from the right, positive values count from the left
Go to
Help==>Scripting Index==Functions==>Character==>Word
for documentation and example
Jim