Page 1 of 1

Sorting versus "picking"

Posted: Fri Sep 05, 2008 3:16 pm
by gyroscope
Hi, I might kick myself when I know the answer to this...

I've a list of words in a field. "Sort" seems to be used only for order of the words/numbers, etc; as far as I can tell; and I can't find the relevant command equivalent to "pick out certain characters or words".

I want to do the following:

Code: Select all

---pseudocode
on mouseDown
put all words starting with the character "c" in field "A" into field "B"
----
---and occasionally:
put all the words containing the characters "d", "h" and "x" in field "A" into field "B"
end mouseDown
If anyone could shed some light on this I'd be most grateful, thanks!

:)

Posted: Fri Sep 05, 2008 4:12 pm
by Janschenkel
You're looking for the 'filter' command - check it out in the Revolution dictionery. Your first request boils down to:

Code: Select all

on mouseUp
  put field "A" into tData
  filter tData with "c*"
  put tData into field "B"
end mouseUp
And your second request would look like:

Code: Select all

on mouseUp
  put field "A" into tData
  filter tData with "*d*"
  filter tData with "*h*"
  filter tData with "*x*"
  put tData into field "B"
end mouseUp
Hope this helped,

Jan Schenkel.

Posted: Fri Sep 05, 2008 11:41 pm
by gyroscope
Thank you Jan, exactly what I was after. I also learned from your code that

Code: Select all

put field "A" into tData
is perfectly acceptable shorthand that works, instead of

Code: Select all

put the text of field "A" into tData
All good stuff...

Thanks again.

:)