User Tag List

Results 1 to 6 of 6

Thread: Text To Integer

  1. #1
    No Products Registered

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

    Text To Integer

    Hi all can you help me ?.

    I have text boxes that load info from an ini file.

    Example: $50,000

    so that I can add up the progressive totals of the text in the boxes as
    they become available I need to change them to integers.

    I'v racked my brains but cannot come up with an answer in MMF2.

    Another way of doing it would be fine

    Thanks

  2. #2
    Clickteam Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform Export ModuleSWF Export Module
    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)
    Simon's Avatar
    Join Date
    Jun 2006
    Location
    UK
    Posts
    2,735
    Mentioned
    65 Post(s)
    Tagged
    3 Thread(s)

    Re: Text To Integer

    As I'm sure you are aware, using the str$() function or retrieve numeric value of edit box returns a 0 when you start including other characters.

    To get around this you can do some stuff with regular expressions (which is fairly advanced). You would need to use "[0-9]" as the regular expression to process the incoming string and filter out all but the characters 0-9.

    Alternatively, you can manually loop through each string with a fast loop, examining a single character at a time using mid$() in the expression editor. Add the character to the end of a new temporary string ONLY if it is a number - by the time you've gone through each character in the original string you'll obviously have stripped all but the numbers then.

    I can't think of anything else obvious right now, hope this helps... if you want me to explain step-by-step about the mid$() method just message me or reply here <img src="/center/images/graemlins/smile.gif" alt="" />

  3. #3
    No Products Registered

    Join Date
    Aug 2006
    Location
    Westcountry, UK
    Posts
    862
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Text To Integer

    Text to Integer:

    Adding up 2 string integers to make a new string:
    [:"blue"]
    str$(val(text1)+val(text2))[/]

    i'm not quite sure if thats what you mean. If there is a currency sign before the number then either save the values without the sign or use:[:"blue"]

    str$(val(Right$(Text1,len(Text1)-1))+val(Right$(Text2,len(Text2)-1)))[/]

  4. #4
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export Module
    UltimateWalrus's Avatar
    Join Date
    Jul 2006
    Posts
    824
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Text To Integer

    You can always write a simple function in Lua to do the dirty work of squeezing out all non-numerical characters. That's probably what I would do, if I couldn't think of any simple pure-MMF solutions :P

  5. #5
    No Products Registered

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

    Many Thanks

    Thank you for taking the time to reply.

    I am working on your answers right now.

  6. #6
    Clicker

    Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export Module
    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)

    Join Date
    Jun 2006
    Location
    Killeen, TEXAS
    Posts
    1,062
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    Re: Many Thanks

    you can always use string parser to remove commas and dollar signs.
    adding text is how raytrace explained. use val("text") to get an integer.

Similar Threads

  1. why always integer value when you set global val.?
    By EasySite in forum Multimedia Fusion 2 - Technical Support
    Replies: 5
    Last Post: 7th July 2010, 03:26 PM
  2. Integer to String in C++
    By Dines in forum Extension Development
    Replies: 6
    Last Post: 20th May 2010, 08:40 AM
  3. real or integer values
    By pikzilla in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 14th April 2009, 10:50 PM
  4. Integer split
    By James in forum Released Extensions
    Replies: 1
    Last Post: 1st August 2007, 03:45 PM
  5. Non-integer scaling
    By BenMo in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 3rd January 2007, 10:54 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
  •