User Tag List

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 18

Thread: How can I test for values in a string

  1. #1
    Forum Moderator

    Fusion 2.5 MacFusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform Export ModuleSWF Export ModuleMac Export ModuleInstall Creator Pro
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)
    Perry's Avatar
    Join Date
    Dec 2013
    Location
    Watertown, WI
    Posts
    4,323
    Mentioned
    44 Post(s)
    Tagged
    0 Thread(s)

    How can I test for values in a string

    If I have a string with "12201212" ( 12 20 12 12 )

    how can I check the string properly to see if there are 3 12's in it and a 20

    I can do mid (string,1,2) = "12" then X=x+1
    I can do mid (string,3,2) = "12" then X=x+1
    I can do mid (string,5,2) = "12" then X=x+1
    I can do mid (string,7,2) = "12" then X=x+1

    I can do mid (string,1,2) = "20" then X=x+1
    I can do mid (string,3,2) = "20" then X=x+1
    I can do mid (string,5,2) = "20" then X=x+1
    I can do mid (string,7,2) = "20" then X=x+1

    But I am thinking that there should be a better way to handle that to tell me how many 12's and 20's are in the string.

    Any help is appreciated

    Thank you

  2. #2
    Clicker Fusion 2.5 Developer

    Join Date
    Jul 2008
    Posts
    1,300
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)
    You could have inserted delimiters in the string, and then a tokenizing extension would have made it marginally easier.
    Otherwise, use a fastloop to loop through the string in pairs.
    eg.
    + whenever...
    -> start loop "loop", len( myString ) / 2 times

    + on loop "loop"
    -> do something with: val( mid$( myString, loopindex( "loop" ) * 2, 2 ))

    Don't forget that you need to add a "0" infront of values lower than 10.
    eg. right$( "0" + str$( someValue ), 2 )

    What you do with that result is up to you. You could use a one-dimensional array to count incidents of each value (so the array index represents the value being counted). You could use a list object and output a list of formatted strings something like this:
    "12:3
    20:1"

  3. #3
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    Bree's Avatar
    Join Date
    May 2014
    Posts
    312
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    That's awesome MuddyMole! I was curious if I could get it to work myself because I've been trying to learn about parsing data as much as possible lately. That's a cool trick!! I was able to get my example working @Perry if this might save you some time, thought I would upload it. I came up with a system for counting how many 12's and how many 20's are in a string after applying MuddyMole's code. Ignore the second button "count values 2"

    Hope it helps!
    Attached files Attached files

  4. #4
    Forum Moderator

    Fusion 2.5 MacFusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform Export ModuleSWF Export ModuleMac Export ModuleInstall Creator Pro
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)
    Perry's Avatar
    Join Date
    Dec 2013
    Location
    Watertown, WI
    Posts
    4,323
    Mentioned
    44 Post(s)
    Tagged
    0 Thread(s)
    Thank you both

    and yes, it can have a , or a : in between.. whichever works better

    how would you do it if it was 12:12:20:12 ?

  5. #5
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    Bree's Avatar
    Join Date
    May 2014
    Posts
    312
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    @Perry , Oh yes you could use the string parser for that format, makes it even easier. Kimera gave me a crash course in it recently. I uploaded an example, hope that's what you were asking!
    Attached files Attached files

  6. #6
    Forum Moderator

    Fusion 2.5 MacFusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform Export ModuleSWF Export ModuleMac Export ModuleInstall Creator Pro
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)
    Perry's Avatar
    Join Date
    Dec 2013
    Location
    Watertown, WI
    Posts
    4,323
    Mentioned
    44 Post(s)
    Tagged
    0 Thread(s)
    Thanks again

  7. #7
    Clicker Fusion 2.5 MacFusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform Export ModuleSWF Export ModuleInstall Creator Pro
    Christian_Wheel's Avatar
    Join Date
    Mar 2010
    Location
    Los Angeles
    Posts
    343
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Use the string parser object to replace "12" with "" and take the difference in the string lengths and divide it by 2. That'll tell you how many 12's you've got. Repeat for 20.

  8. #8
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    Bree's Avatar
    Join Date
    May 2014
    Posts
    312
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    That's another cool idea, creative thinking

  9. #9
    Forum Moderator

    Fusion 2.5 MacFusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform Export ModuleSWF Export ModuleMac Export ModuleInstall Creator Pro
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)
    Perry's Avatar
    Join Date
    Dec 2013
    Location
    Watertown, WI
    Posts
    4,323
    Mentioned
    44 Post(s)
    Tagged
    0 Thread(s)
    Looked in the help for the String parser, but must be missing something

    From the help file:
    Syntax : replace$(szObject, szFind, szNew)
    Comments: Returns a string with all occurrences of the specified search substring replaced by the new substring. This function can use wildcards.
    Example: replace$("String Parser", "-old-", "new")

    So I did

    (parser).Set Source String = replace$(string$( "parser" ), "12", "")
    but gives me a Syntax Error ?

  10. #10
    Forum Moderator

    Fusion 2.5 MacFusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform Export ModuleSWF Export ModuleMac Export ModuleInstall Creator Pro
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)
    Perry's Avatar
    Join Date
    Dec 2013
    Location
    Watertown, WI
    Posts
    4,323
    Mentioned
    44 Post(s)
    Tagged
    0 Thread(s)
    I'm getting stuck on what I am trying to achieve.

    I included an example.

    1. the listbox on the left has all the values
    2. the listbox in the middle is just splitting up the numbers
    3. the listbox on the right just shows the same number so i could check

    I want to show in the bottom list a line for each line from the other box, telling me what's in it

    like
    10101020 will tell me that there are 3 x 10 and 1 x 20
    10111112 will tell me that there are 1 x 10, 2 x 11 and 1 x 12

    I was trying to loop and fill a Global var to keep track of the totals and clear for the next line, but cannot figure out the logic in this case.

    Any thoughts?
    Attached files Attached files

Page 1 of 2 1 2 LastLast

Similar Threads

  1. Can you test if a string has been changed?
    By ChrisBurrows in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 11th November 2011, 02:41 PM
  2. Will String objects have alt.values?
    By Blizna in forum Multimedia Fusion 2 - Technical Support
    Replies: 23
    Last Post: 21st April 2009, 05:13 AM
  3. String -> Values?
    By Jesse in forum Multimedia Fusion 2 - Technical Support
    Replies: 7
    Last Post: 22nd October 2007, 06:21 AM

Posting Permissions

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