Searching text
In this recipe, we will prompt the user for some text and then prompt him/her for text to search for. We will evaluate the first set of text to determine if the second bit of text is contained within the first. We will provide the user with the results.
How to do it...
Follow this recipe's steps to create functionality that asks for input of the text that is to be searched for and the text that is to be analyzed with the search criteria:
Create a new main stack in LiveCode.
Drag a button to the card.
Add the following code to the new button:
on mouseUp local sourceText, searchText ask question "Enter text to search:" titled "SOURCE TEXT" put it into sourceText -- ask question "Enter text to search for:" titled "SEARCH TEXT" put it into searchText -- if searchText is among the words of sourceText then answer "text found" else answer "text not found" end if end mouseUp
Run the application in a simulator and enter the text shown in the following screenshot...