Page 1 of 1

Character Position Of Word in Field

Posted: Fri Oct 01, 2010 6:15 pm
by warrenk
What would be the easiest way to get the character positions of a word in a field?

ie (pseudo code)
get beginning and/or end character postion of word x in field "My Text"

Thanks for any help!
Warren

Re: Character Position Of Word in Field

Posted: Fri Oct 01, 2010 10:16 pm
by jmburnod
Hi,

You can try this script.
startEndWord return the position of the fist char and the position of the last char of the word

Code: Select all

on mouseUp
   put startEndWordInFld(TheWord,fld 1)
end mouseUp

function startEndWordInFld pWord,pText 
   put empty into rStartEndWordInFld
   put the num of chars of pWord into nbc
   put offset(pWord,pText) into startW
   put startW+nbc-1 into endW
   put "char"&&startW&&"to"&&endW into rStartEndWordInFld
   return rStartEndWordInFld
end startEndWordInFld

Best

Jean-Marc