Single Digit to Double Digit
Can I use the expression editor to make a single digit 0-9 number double digit, so 00-09? I'm dealing with time here, so hours/minutes/seconds. It would take a number of conditions to check if all three values are 0-9 at once, so if there's an easy solution for this I'd like to know.
Thanks.
Re: Single Digit to Double Digit
Found an old thread. Mods may as well delete this unless someone else might find this useful.
http://www.clickteam.com/epicenter/ubbthreads.php?ubb=showflat&Number=192423
Re: Single Digit to Double Digit
Situation not averted. :( I'm trying to use this, keep in mind CurrentSecond is a global variable.
Str$( Left$("0",2-Len(Str$(value(CurrentSecond))))+Str$(value(Curren tSecond)) )
The number two is causing the problem. I'm not very good with expressions so I'm probably doing something very stupid. Anyway, I'd appreciate any help.
Re: Single Digit to Double Digit
Assuming you are using two counters, could you not simply say, "If counter 1 = 99" then add to the condition "If counter 2 = 99", do etc.
Re: Single Digit to Double Digit
What you're doing here is taking as many characters as needed from the string "0" to fill up the remainder of the string (one 0 if the original value is 1 digit long, or none if it's two - therefore, (2 - the length of the original string) zeroes), then putting the original value (in string form) after it.
If the value is 1 digit long (e.g. "7"):
Left$("0", 2-1) = "0" (the first 1 characters of the string "0") + "7"
= "07"
If the value is 2 digits long (e.g. "94"):
Left$("0", 2-2) = "" (No characters of the string "0") + "94"
= "94"
So the expression is - set string to:
Left$("0", 2-Len(Str$(value(CurrentSecond)))) + Str$(value(CurrentSecond))
You appear to have rather more brackets and stages than necessary in your original expression, but it's difficult to tell without syntax highlighting.
Re: Single Digit to Double Digit
Yeah, I forgot to remove the Str$ at the beginning which I added hoping it would help. Otherwise it's the same as on the link I provided above. I have nothing to do with the expression that's written, other than adding in the global values.
http://img714.imageshack.us/img714/2791/expreditor.png
Ausomeman, I'm not using counters. I'm retrieving the system date and time and setting global values to these numbers.
Re: Single Digit to Double Digit
Oh, I never noticed you were using global values - you don't need value(), in that case. That's for retrieving the value of a counter object.
Left$("0", 2-Len(Str$(CurrentSecond)))+Str$(CurrentSecond)
Re: Single Digit to Double Digit
Ah, right! It works, thanks.
Re: Single Digit to Double Digit
There is a simple option on the counters somewhere that allows them to be displayed with multiple digits. so one is displayed as 01. no need for events.
Re: Single Digit to Double Digit
That is true. But when converted to string, it becomes single digit.