Identify text from a text field

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
liveCode
Posts: 124
Joined: Sun Oct 17, 2021 5:53 pm

Identify text from a text field

Post by liveCode » Sun Oct 13, 2024 2:12 pm

What is the code for identifying certain words from a text field? (I also want to get the row number)

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

Re: Identify text from a text field

Post by Klaus » Sun Oct 13, 2024 2:43 pm

liveCode wrote:
Sun Oct 13, 2024 2:12 pm
What is the code for identifying certain words from a text field? (I also want to get the row number)
You can use -> lineoffset that will give you the line number (= row)

Code: Select all

...
put "whatever" into tWord2Search4
put lineoffset(tWord2Search4,fld "the textfield") into tLineNumber
answer tLineNumber
## Will give you the line number with the FIRST occurrence of that word or 0 (Zero),
## if the word is NOT in the text of the field
...

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

Re: Identify text from a text field

Post by dunbarx » Sun Oct 13, 2024 3:14 pm

Hi.

Not sure what you mean about "identify". Here is a handler that "identifies" a word in a field 1. In a button script:

Code: Select all

on mouseUp
   ask "Find?"
   find empty
   repeat 
      find it in fld 1
      put the foundChunk & return after temp    
      if the result = "not found" then exit repeat
   end repeat
   answer temp
end mouseUp
Craig

liveCode
Posts: 124
Joined: Sun Oct 17, 2021 5:53 pm

Re: Identify text from a text field

Post by liveCode » Fri Nov 01, 2024 12:02 pm

Hi. Thanks for the code. I would also like a code that gives "TRUE" or "FALSE" depending on whether the certain word is in the text
thanks

SWEdeAndy
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 324
Joined: Sat Aug 16, 2008 9:48 am
Contact:

Re: Identify text from a text field

Post by SWEdeAndy » Fri Nov 01, 2024 12:39 pm

liveCode wrote:
Fri Nov 01, 2024 12:02 pm
Hi. Thanks for the code. I would also like a code that gives "TRUE" or "FALSE" depending on whether the certain word is in the text
thanks
That is beautifully simple in LiveCode:

Code: Select all

answer tMyWord is in field 1
Andreas Bergendal
Independent app and system developer
Free LC dev tools: https://github.com/wheninspace
(WIS_WebDeployHelper, WIS_ScriptDependencies, WIS_BrowserAnimation)
WhenInSpace: https://wheninspace.com

Post Reply