problem with counting words

Kay C Lan lan.kc.macmail at gmail.com
Sun Oct 12 21:58:29 EDT 2014


On Mon, Oct 13, 2014 at 7:45 AM, Richard Gaskin <ambassador at fourthworld.com>
wrote:

>
> I hear ya', but like so many other oddities in the language this one came
> from Apple,
>

Sheer brilliance! One of the first analogies of HyperCard was that it was a
an electronic rolodex. Here is a list of names:

Abu Musab    Al-Zarqawi
Camilla Parker-Bowles
Catherine    Zeta-Jones
Claude Levi-Strauss
D'Arcy    Corrigan
Daniel  Day-Lewis
David    Ben-Gurion
Dodi Al-Fayed
Florence    Griffith-Joyner
Gilbert  O'Sullivan
Gloria    Macapagal-Arroyo
Jean-Claude Van Damme
Jimmy    O'Dea
Justine  Henin-Hardenne
Kareem    Abdul-Jabbar
Karim Abdul-Jabbar
Kristin    Scott-Thomas
Maddox  Jolie-Pitt
Michael    O'Leary
Olivia Newton-John
Peter    O'Toole
Sinéad O'Connor
Tim    Brooke-Taylor
Ralph Twistleton-Wykham-Fiennes

So lets say you want to sort these by surname - a kind of rolodex thing to
do.

sort lines of myListOfNames by word  of  -1 each

will result in only one mistake

sort lines of myListOfnames by trueword -1 of each --if you are on LC7.0

will result in basically the same messed up result most other programming
languages will give you. Put it in and word processor and see how you go.

Please feel free to try and write your own function that is more successful
and more efficient than the beautiful one liner Bill Atkinson gave us. Even
if you had wordDel it wouldn't help much. I can't imagine the amount of
hours that have been wasted, especially on genealogical websites, trying to
unfathom why double barrelled names never sort correctly. This is also
compounded by the certain fact that some people will put a space between
the last given name and the Surname, some a tab, and some will 'format' the
data by placing multiple spaces in between names so that things 'line up
nicely' - and are then confused as to why it only looks that way on their
screen an not on someone else's. One of the reasons double barrelled names
have picked up the '-' is to help computers recognise them as a single word.

Also;

put myVariable into fld Not A Variable

doesn't work

put myVariable into fld "Not A Variable"

does. The ability to recognise words in quote as a single entity is
extremely important. Yes, we don't typically think of such as a single
word, but when we understand that computers don't think like us, and we do
understand why things are the way they are, such oddities can be
manipulated in many powerful ways to our own advantage. It is also helpful
when we understand such things that we don't go around replacing one
character willy nilly with another character. ~ [tilde] for instance is one
character I'd never use as it has a special meaning in many computer
languages; as does / \ < > . * and many others. If we had some text that
contained both straight and curly quotes and replaced the straight quotes
with curly quotes so we could get a word count, and then changed the curly
quotes back to straight quotes, the finL text is not the same as it started
- and this could cause problems. Today your function might work perfectly
for today's problem, but next month, or next year, when you start expanding
your LC skills and try working with SQL databases, or Servers and network
connections, every now and then someone will report a bug that your app
does something strange. You may never be able to track it down because it
just happens that once every million DB calls a random user happens to use
data that contains a character that you never use yourself and thought no
one else would. I have a particular liking to numToChar(127) myself.

Yep, no other programming language might define a word like LC defines a
word, but I for one am EXTREMELY thankful for that.



More information about the use-livecode mailing list