User Tag List

Results 1 to 8 of 8

Thread: How to return integer as 01 rather than 1 in a string?

  1. #1
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export Module

    Join Date
    Jan 2012
    Posts
    95
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to return integer as 01 rather than 1 in a string?

    Hi I have some code that returns an integer to a string and mods it by 12 or 60 for hours and minutes eg 12:10
    however when its 1:01 or returns as 1:1. Is there a way to force a pre 0 digit if the number is less than 9? Thanks

  2. #2
    Clicker Fusion 2.5 DeveloperAndroid 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)
    Popcorn's Avatar
    Join Date
    Jun 2006
    Location
    Norway, Bergen
    Posts
    2,366
    Mentioned
    13 Post(s)
    Tagged
    0 Thread(s)
    I would check if the returned value is below 10, and in that case add a "0" before the digit.
    If you absolutely have to do it in one event, you could store the values 0 to 60 in a list, and pick the linenumber that equals the returned value. So if it returns 1, it picks line number one which says "01".

  3. #3
    Clicker Fusion 2.5 DeveloperiOS Export Module
    ChrisBurrows's Avatar
    Join Date
    May 2011
    Location
    Tasmania, Australia
    Posts
    622
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    MuddyMole posted a 1 line expression for this a few days ago.

  4. #4
    Clicker Fusion 2.5 Developer

    Join Date
    Jul 2008
    Location
    UK
    Posts
    1,393
    Mentioned
    16 Post(s)
    Tagged
    0 Thread(s)
    Right$("0" + str$( value ), 2)

  5. #5
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export Module

    Join Date
    Jan 2012
    Posts
    95
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by MuddyMole View Post
    Right$("0" + str$( value ), 2)
    Won't that add it to all of them so the time might come up as 012:059 ?

  6. #6
    Clicker Fusion 2.5 Developer

    Join Date
    Jul 2008
    Location
    UK
    Posts
    1,393
    Mentioned
    16 Post(s)
    Tagged
    0 Thread(s)
    Yeah. You said you already had the code to get hours and minutes separately?

    Let's say your single value is the time in total minutes:

    Str$(( Time / 60) mod 12) + ":" + Right$("0" + Str$( Time mod 60), 2)

  7. #7
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCSWF Export Module
    Alonso's Avatar
    Join Date
    Jul 2006
    Posts
    681
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I made a workaround to this problem by always adding 1000 when modifying the value (so 1 becomes 1001, 12 becomes 1012), then just getting the last two characters of the digit, using right$(string, 2). If there's a better way, I'd like to know (:.

  8. #8
    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)
    Try Left$("0", 2-Len(Str$(value)))+Str$(value)
    It's colourful so you know it's authentic!

Similar Threads

  1. Use the string parser to return a number?
    By MrXkill in forum Multimedia Fusion 2 - Technical Support
    Replies: 9
    Last Post: 29th July 2011, 03:19 PM
  2. Mochi Social return "null" string...
    By Orelbe in forum SWF/Flash Export Module Version 2.0
    Replies: 4
    Last Post: 24th July 2011, 04:51 PM
  3. Integer to String in C++
    By Dines in forum Extension Development
    Replies: 6
    Last Post: 20th May 2010, 08:40 AM
  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
  •