Book Image

LiveCode Mobile Development Cookbook

By : Dr. Edward Lavieri
Book Image

LiveCode Mobile Development Cookbook

By: Dr. Edward Lavieri

Overview of this book

Table of Contents (17 chapters)
LiveCode Mobile Development Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

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:

  1. Create a new main stack in LiveCode.

  2. Drag a button to the card.

  3. 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
  4. Run the application in a simulator and enter the text shown in the following screenshot...