Words without quotes

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9359
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Words without quotes

Post by richmond62 » Mon May 17, 2021 11:25 am

I am currently knocking up a word frequency counter . . .

Now my "customer" (OK, OK, my younger son) wants to be able to differentiate between "NATO" and NATO.

Using trueword it is dead easy to find all the occurrences of "NATO" with quotes by entering "NATO" in my search thing:
-
NATO.png
-
That gives me all the occurrences of "NATO".

However, if I enter NATO (without quotes) I get the occurrences of both "NATO" and NATO, and that is no good.

stam
Posts: 2679
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Words without quotes

Post by stam » Mon May 17, 2021 11:43 am

Does search for text formatted as

Code: Select all

quote & "NATO" & quote
make any difference?

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9648
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Words without quotes

Post by dunbarx » Mon May 17, 2021 2:32 pm

Hi,

Try this. On a new card with a button and a field, put this in the button script:

Code: Select all

on mouseUp
   get fld 1
   repeat for each word tWord in it
      add 1 to wordCount[tWord]
   end repeat
   breakpoint
end mouseUp
Put this in the field:

Code: Select all

nato "nato" nato "nato" nato
Click the button, look at the array variable "wordCount".

How much do you charge your son?

Craig

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7228
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Words without quotes

Post by jacque » Mon May 17, 2021 4:54 pm

Craig's right, use "word" to include quotes. To avoid matches that occur within words, I'd check the search term for quotes and if they exist, use "word" and if not, use "trueword".
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”