User Tag List

Results 1 to 10 of 10

Thread: Expressions and String Comparisons?

  1. #1
    Clicker Fusion 2.5

    Join Date
    Sep 2006
    Posts
    280
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Expressions and String Comparisons?

    Probably a silly question: I know you can compare numerical values for greater than, less than, equal to, different than, etc.; and when it comes to using numbers, it's straight forward. Now, this is probably a silly question, but when it comes to strings, how do the greater than and less than comparisons function?

    What would be greater than or less than the string... erm... "Orange" for example?

  2. #2
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export Module
    Fusion 2.5 (Steam)
    schrodinger's Avatar
    Join Date
    Nov 2014
    Posts
    3,159
    Mentioned
    28 Post(s)
    Tagged
    1 Thread(s)
    I think the same "rules" as Windows does with sorting, i.e. for filenames etc.:

    The sorting functions compare two strings by checking the first characters against each other, the second characters against each other, and so on until they find an inequality or reach the ends of the strings. These functions return the difference of the values of the first unequal characters they encounter. For example, lstrcmp determines that "abcz" is greater than "abcdefg" and returns the difference of the code-point numbers that correspond to "z" and "d." The selected user locale determines which string is greater (or whether the strings are the same)

    So:
    123456
    will come before
    124
    (even if 124 is a much smaller number)

    but:
    123455
    will come before
    123456


    so "oramge" is lower than "orange"
    but "oraoge", or "orbnge", or even "orc" are bigger

  3. #3
    Clicker Fusion 2.5

    Join Date
    Sep 2006
    Posts
    280
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I see. That being said, would "orange juice" be greater than "orange"?

    Actually, say if you have multiple events looking at multiple objects with different Alterable Strings.

    "Orange"
    "Orange Juice"
    "Orange Soda"
    "Tomato"

    How would you make an event find all Alterable Strings greater than or equal to "Orange" while it only finds those that at least contain the word "Orange" in them, so that it doesn't grab "Tomato"?

  4. #4
    Clicker Fusion 2.5Android Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)
    Vetmora's Avatar
    Join Date
    Jul 2010
    Location
    Australia
    Posts
    142
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  5. #5
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export Module
    Fusion 2.5 (Steam)
    schrodinger's Avatar
    Join Date
    Nov 2014
    Posts
    3,159
    Mentioned
    28 Post(s)
    Tagged
    1 Thread(s)
    Yes "Orange Juice" is bigger than "Orange"
    (the first character different in the two strings is " ", which is bigger than "" )

    Assuming you are iterating through all your objects,
    you would do something like:

    on each one of "my_object"
    >>> set global value "pick_instance" to fixed value("my_object")
    >>> start loop "check_strings" (number of alt. strings you have times)

    on loop "check_strings"
    +fixed value of "my_object" = pick_instance
    +Find(AltStrN$( "my_object",( loopindex("check_strings")), "Orange", 0) >= 0
    +AltStrN$( "my_object",( loopindex("check_strings")) >= "Orange"
    >>> this strings meets the requirements! (do stuff with it...)

  6. #6
    Clicker Fusion 2.5

    Join Date
    Sep 2006
    Posts
    280
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is there a way to do it as a much simpler condition by chance?

    Alterable Value A >= "Orange"
    Alterable Value A contains "Orange"

    I've a feeling having a loop inside of another loop for every instance of every object that will have these Alterable Strings will cause quite a bit of slowdown. And unfortunately, a lot of that looks like Greek to me.

    Also, Snail's example no longer exists in that link.

  7. #7
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export Module
    Fusion 2.5 (Steam)
    schrodinger's Avatar
    Join Date
    Nov 2014
    Posts
    3,159
    Mentioned
    28 Post(s)
    Tagged
    1 Thread(s)
    No way - if you want to check every single alt. string of each object,
    ...you have to check every single alt. string of each object

    You could do that "manually" without the nested loop,

    i.e.

    altstring1 contains "orange"
    +altstring 1 >= orange

    altstring2 contains "orange"
    +altstring 2 >= orange

    altstring3 contains "orange"
    +altstring 3 >= orange

    but this won't change much (if anything at all) in processing speed

    above example is quite short anyway (just two events)
    if it's not clear I can provide an example of it?

  8. #8
    Clicker Fusion 2.5

    Join Date
    Sep 2006
    Posts
    280
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Examples are always nice. :p

    And I actually would only need something that says "altstring1 contains 'orange'" in it, if of course there's an event for that.

  9. #9
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export Module
    Fusion 2.5 (Steam)
    schrodinger's Avatar
    Join Date
    Nov 2014
    Posts
    3,159
    Mentioned
    28 Post(s)
    Tagged
    1 Thread(s)
    here's a super quick example:

    find_orange.mfa

    let me know if any doubt

  10. #10
    Clicker Fusion 2.5

    Join Date
    Sep 2006
    Posts
    280
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think that was probably much easier shown than explained. Haha. Apparently there's a ton of expressions and events I have no idea even exist, but that's exactly what I was looking for. Literally just one conditioned line (in addition to A.S. >= "orange").

    Thanks again!

Similar Threads

  1. Multiple comparisons at the same time
    By marius in forum Fusion 2.5
    Replies: 6
    Last Post: 2nd March 2016, 07:50 PM
  2. [Bug] Basic comparisons failing
    By Mokhtar in forum SWF/Flash Export Module Version 2.0
    Replies: 7
    Last Post: 21st May 2010, 04:06 PM
  3. String Comparisons In Lua Code?
    By Atom in forum Lua Scripting
    Replies: 6
    Last Post: 3rd May 2010, 10:19 PM
  4. Application Comparisons
    By artician in forum The Games Factory 2 - Technical Support
    Replies: 3
    Last Post: 16th May 2008, 12:10 AM
  5. Direction comparisons
    By Dines in forum Multimedia Fusion 2 - Technical Support
    Replies: 11
    Last Post: 2nd March 2008, 06:41 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
  •