User Tag List

Results 1 to 5 of 5

Thread: Adding zeroes to the beginning of a number

  1. #1
    No Products Registered

    Join Date
    Jul 2006
    Posts
    492
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Adding zeroes to the beginning of a number

    Hi,

    I'm writing a pathfinding algorithm for my AI that stores the path waypoint coordinates in an alterable string of the enemy. For example, if i had a path given by points [3,4] [4,4] [4,5] the alterable string should read

    "000300040004000400040005"

    I will then use string functions to traverse the list each time a path node is reached. What I want to know is this; is there any simple way of formatting a string representation of a number to be a certain number of characters long? (i.e. if it is less then leading zeroes will be added).

  2. #2
    Clicker Multimedia Fusion 2 DeveloperSWF Export Module

    Join Date
    Jun 2006
    Posts
    6,773
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Re: Adding zeroes to the beginning of a number

    (Left$("00000",5-Len(MyString))+MyString)

    That will pad the string to 5 digits - to increase or decrease this limit, add or remove zeroes from the string and increase or decrease the 5 constant.

  3. #3
    No Products Registered

    Join Date
    Jul 2006
    Posts
    492
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Adding zeroes to the beginning of a number

    Oops, I just literally thought of a solution to this when I clicked the submite version. In any case, this might be helpful to people in future so heres what i did:

    Right$("0000"+Str$(<number>), 4)

    this adds 4 leading zeroes to the number then deletes some of them again so that the number is only 4 characters long.

  4. #4
    No Products Registered

    Join Date
    Jul 2006
    Posts
    492
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Adding zeroes to the beginning of a number

    hehe snap Jamie, cheers!

  5. #5
    Clicker Multimedia Fusion 2 Developer

    Join Date
    Jun 2006
    Location
    Darlington, UK
    Posts
    3,298
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Adding zeroes to the beginning of a number

    Yours is shorter

Similar Threads

  1. How to increase number of lives at the beginning.
    By Emerald41 in forum Multimedia Fusion 2 - Technical Support
    Replies: 5
    Last Post: 18th June 2017, 07:10 PM
  2. MP3 Object Beginning Development.
    By Max in forum Extension Development
    Replies: 23
    Last Post: 31st July 2011, 09:42 PM
  3. Load all music at beginning of game?
    By Viewtiful in forum Multimedia Fusion 2 - Technical Support
    Replies: 4
    Last Post: 3rd October 2009, 08:15 PM
  4. Beginning again
    By Martin_R_Bodger in forum Multimedia Fusion 2 - Technical Support
    Replies: 10
    Last Post: 29th February 2008, 08:45 AM
  5. Strange noise at the beginning/end of Wavs
    By JoKa in forum Multimedia Fusion 2 - Technical Support
    Replies: 11
    Last Post: 10th December 2006, 09:48 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
  •