Sign in to follow this  
Followers 0
DoubleMcLovin

forcing my integers to be x digits long...

4 posts in this topic

#1 ·  Posted (edited)

I'm working on a downloader script, I have the server configuration all set but my integers keep showing up as 01 rather than 001. I have it set as $x = 000 and then increment through $x += 1

Edited by DoubleMcLovin

Share this post


Link to post
Share on other sites



Check out function StringFormat. Should be able to do what your looking for.

Share this post


Link to post
Share on other sites

That is by far one of the most confusing man pages I have read so far...

After about 20minutes of fiddling with it I am still unable to properly manipulate this command. If there is anyone that can help me understand this command or show me how to do this I would be much abliged. I got as far as: $volume = StringFormat("%%02 = [%02]\n", $volume) which did me no good at all...

My current alternative is about 15 variations of

If $chapter < 10 Then
                $curl &= "-00" 
            ElseIf $chapter < 100
                $curl &= "-0"
            ElseIf $chapter >= 100
                $curl &= "-" 
            EndIf
And that just looks terrible all over my code (I would seriously need about 15 instances of that format of code... this should be able to be done with like 2 lines declaring that they must be 2 or 3 digits...

Share this post


Link to post
Share on other sites

You want your numbers

001

002

003 and so on right? If so look at this.

For $i = 1 to 100
    $x = StringFormat('%03s', $i)
    ConsoleWrite( $x & @CRLF)
Next

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0