User Tag List

Results 1 to 5 of 5

Thread: How to test if a string object contains a specific text

  1. #1
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleSWF Export ModuleUnicode Add-on
    Boba Fonts's Avatar
    Join Date
    Jan 2009
    Location
    Northern Italy
    Posts
    228
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to test if a string object contains a specific text

    Same as the thread title. For an educational program I need students to type an answer to a certain question, 'cause this one can't be done with combo boxes or checkboxes. There are many ways they could type the answer, but the "critical" words (apart from articles, prepositions, punctuation, spaces, etc.) are a few, and those words definitely must be in the answer. How can I test if a text string (or Edit Box, which I'm going to use) contains given texts? thanks

  2. #2
    Clickteam Clickteam
    LB's Avatar
    Join Date
    Jun 2007
    Location
    Richardson, Texas, North America
    Posts
    8,937
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    You can convert it to lowercase with the Lower$() function, to make it case insensitive. You can then search for a string in a string with the Find() function. Both of these can be found as expressions under the Special Object -> Strings ->
    Working as fast as I can on Fusion 3

  3. #3
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleSWF Export ModuleUnicode Add-on
    Boba Fonts's Avatar
    Join Date
    Jan 2009
    Location
    Northern Italy
    Posts
    228
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks LB.
    So, just to understand how Find() works, I've tried to figure out which condition I can use with those expressions. I've tried "Compare two general values" this way but I'm certainly messing things:

    Find(Lower$(Edittext$( "Edit Box" )), "clickteam", 3)
    =
    3

    but as far as I understand it only checks if the searched text "clickteam" starts at the defined position (fourth character in this case, after three previous characters), otherwise it's false even if the string of text is indeed present somewhere.
    How can I test if the string to be found is there at all, regardless of its position?

  4. #4
    Clicker Fusion 2.5 MacFusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export ModuleUnicode Add-on
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)Firefly 3D Module (Steam)
    Phi's Avatar
    Join Date
    Jan 2010
    Location
    England
    Posts
    1,964
    Mentioned
    25 Post(s)
    Tagged
    0 Thread(s)
    0 is the first character. You specify which character to begin the search on in the final parameter of Find(). If it is located, the returned value of Find will be 0+, to indicate the index of the find.
    Some examples:
    Find("abc","b",0) == 1
    Find("abc","b",1) == 1
    Find("abc","b",-1) == -1 (invalid search index - so not found)
    Find("abc","b",2) == -1 (not found, as the search started on "c")
    Find("abc","b",60) == -1 (invalid search index - so not found)
    Find("abc","c",0) == 2
    Find("abc","c",1) == 2
    Find("abc","c",2) == 2

  5. #5
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleSWF Export ModuleUnicode Add-on
    Boba Fonts's Avatar
    Join Date
    Jan 2009
    Location
    Northern Italy
    Posts
    228
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I test for the wanted string starting from character numer 0, i.e. in the whole text, and if it's = -1 then is false, it isn't there; if is <> -1 it has been found. Thank you all, now it's clear.

Similar Threads

  1. String object not centralising text
    By Raudaschl in forum iOS Export Module Version 2.0
    Replies: 6
    Last Post: 5th February 2013, 06:06 PM
  2. Rich Text Object - Get specific line and letter
    By HadHaw in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 2nd February 2013, 07:28 PM
  3. Set edit box text to string$("string object") causes long delay
    By MJK in forum XNA Export Module Version 2.0
    Replies: 4
    Last Post: 22nd August 2012, 02:58 PM
  4. Text Bug in String object
    By TheOriginator in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 28th February 2012, 09:11 AM
  5. Hyperlink text in string object?
    By mobichan in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 20th October 2011, 06:02 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •