nother newbie question this time re foundChunk

Timothy Miller gandalf at doctorTimothyMiller.com
Wed Mar 23 02:25:32 EDT 2011


Hi again.

I'm working on an indexing script.
The relevant portion of my script so far: (it works thanks to you guys)

  repeat until the shiftKey is down
      set cursor to busy
      put the number of this card into firstNum
      find tTempSearch in field "narrative"
      put the foundChunk into tFound
      put the result into tResult
      put the number of this card into secNum
      if word 2 of tFound > 30 then subtract  30 from word 2 of tFound
      add 30 to word 4 of tFound
      put value(tFound) && "Card ID" & the short ID of this card & cr & cr after tFoundList
      if tresult = "not found" then exit repeat
      if firstnum > secnum then exit repeat
   end repeat

At the climax of the script, variable tFoundList gets put into a (cleverly clickable) field on the index card. I can see thirty characters before and after the word or string I searched for, so I can see the searched-for word in context. This will be a more useful index, for my purpose.

The trouble is, I end up with fragmentary words in my index field. They look crappy and they're distracting.

I'm trying to figure out a way to end up with a consecutive sequence of whole words in each line of the index field.

I'm hoping there's a function that works with the "find" command to return something like "word 88 of field 1" As far as I can tell, nothing like that exists. If it did, I could put it into a variable, manipulate it until it looks like "word 78 to 98 of field 1" and then get its value.

If that isn't possible, I guess I will have to get the foundChunk and mess with it, to count backward and forward until I encounter " " or cr characters. This will be slow, and it will take me forever to script, though I am capable of getting it right in the end, howsoever kludgily.

I tried "the foundText" but as far as I can tell, it returns value(the foundChunk). Not what I need. I tried "find word" but the foundChunk still returns characters, not words.

Am I missing anything?

Thanks again,

Tim (the perpetual newbie)



More information about the use-livecode mailing list