Find whole or find word with apostrophe

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
JackD
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 28
Joined: Sat Mar 14, 2009 3:17 am

Find whole or find word with apostrophe

Post by JackD » Tue May 28, 2013 6:59 pm

I'm having a problem with the find command when a field contains an apostrophe. A statement like
find whole "s" or find word "s"
stops at each 's (apostrophe s, as in it's) in the field.

I'm searching an index for a line that has only an S in it. The only workaround that I can figure out is a loop that repeats the find until the line = "S". Is there a simpler way to do this in LiveCode?
27" iMac, OS X 10.13
iPad 3, iPad Pro, iPhone 4s, iPhone 6, LG Optimus L9 phone, Samsung Galaxy Camera
LiveCode 8.1.9

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4174
Joined: Sun Jan 07, 2007 9:12 pm

Re: Find whole or find word with apostrophe

Post by bn » Tue May 28, 2013 8:14 pm

Hi JackD,

if the s you are looking for is an uppercase S then you could

Code: Select all

set the caseSensitive to true
if not it gets a bit more involved

Kind regards
Bernd

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10356
Joined: Wed May 06, 2009 2:28 pm

Re: Find whole or find word with apostrophe

Post by dunbarx » Tue May 28, 2013 8:51 pm

I am not seeing this. And I was worried when I read your post. If I have a field with text in it:

aaa bbb ccc's ddd
eee ccc's ggg
hhh ccc's kkk

find whole "ccc's" finds each instance of "ccc's", complete. You can even find them all in a repeat loop:

on mouseUp
repeat 3
find whole"ccc's" in fld "f44"
wait 44
end repeat
end mouseUp

Craig Newman

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4174
Joined: Sun Jan 07, 2007 9:12 pm

Re: Find whole or find word with apostrophe

Post by bn » Tue May 28, 2013 9:03 pm

Hi Craig,

as far as I understand it is the other way around. Jack wants to find a single S. He uses find word. That also finds the s in Craig's. That is the problem.

try

Code: Select all

on mouseUp
   -- set the caseSensitive to true
   set the wholeMatches to true
   find word "S" in field 1   
end mouseUp
on

Craig's
S
s
Sumatra

Kind regards
Bernd

JackD
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 28
Joined: Sat Mar 14, 2009 3:17 am

Re: Find whole or find word with apostrophe

Post by JackD » Tue May 28, 2013 10:05 pm

Bernd is correct, I'm searching for a single S. The wholeMatches doesn't make a difference in my stack but caseSensitive does so I'll use that. I really didn't want to use a loop to find it. Thanks Bernd.
27" iMac, OS X 10.13
iPad 3, iPad Pro, iPhone 4s, iPhone 6, LG Optimus L9 phone, Samsung Galaxy Camera
LiveCode 8.1.9

Klaus
Posts: 14213
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Find whole or find word with apostrophe

Post by Klaus » Wed May 29, 2013 2:00 pm

Hi Jack,

you are searching a LINE that consist from a single capital S?
Then use LINEOFFSET:
...
set the wholematches to TRUE
put lineoffset("S",fld 1)
...


Best

Klaus

Post Reply