|
Phanku Novice
Joined: 09 Oct 2003 Posts: 40
|
Posted: Wed Jun 16, 2004 2:32 am
Concat And Or Format? |
Okay you guys. I have on my status bar an alarm that ticks down time for something to happen.
It looks like
Reboot: 1:54:9
I'm a bit of a picky person, so I want to put a zero infront of that nine. I have tried
Code: |
%format("&2.0n",%concat(0,@reboot_second)) |
This does not work.
I've also tried
Code: |
%format("&2.0n",0,@reboot_second) |
Course this doesn't work ither.
I have done this once before a long time ago, and i just can't remember how i did it.
If you guys could tell me how to do it again, that would be great.
Thanks
Phanku |
|
|
|
Danlo Magician
Joined: 28 Nov 2003 Posts: 313 Location: Australia
|
Posted: Wed Jun 16, 2004 5:51 am |
A concat will work fine:
%if(%len(@rebootsecond)=1,%concat("0",@rebootsecond),@rebootsecond) |
|
|
|
Phanku Novice
Joined: 09 Oct 2003 Posts: 40
|
Posted: Wed Jun 16, 2004 6:08 am |
Isn't there a way to do it with out the %if statement.
I remember once along time ago, there was just a way to format it using two functions that it would just come out right, while not using the %if functions. |
|
|
|
Danlo Magician
Joined: 28 Nov 2003 Posts: 313 Location: Australia
|
Posted: Wed Jun 16, 2004 6:18 am |
%format function only pads it with spaces, not with preceding zeros, if its not the right length. An %if statement like the one above is the best way to do it, however, there is another way:
%replace(%format("&2.0n",@Reboot_Seconds)," ","0") |
|
|
|
Serentus Apprentice
Joined: 28 Sep 2001 Posts: 103 Location: USA
|
Posted: Wed Jun 16, 2004 8:56 am |
or you can try
%right(%concat("0",@Reboot_Seconds),2) |
|
|
|
Phanku Novice
Joined: 09 Oct 2003 Posts: 40
|
Posted: Wed Jun 16, 2004 1:32 pm |
Danlo, that is exactly what i was looking for..
Grrr, why didn't i think of using the replace function...
Thanks |
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Wed Jun 16, 2004 5:03 pm |
%if( @reboot_second < 10, 0)@reboot_second
|
|
|
|
Phanku Novice
Joined: 09 Oct 2003 Posts: 40
|
Posted: Sun Jul 18, 2004 12:51 am |
Thanks LightBulb for answering.
The information you supply is allways helpfull. The solution you posted here is the one my partner came up with. But I didn't like the idea of using an if function in the status bar.
So I have a question, Which is better (if there is a difference) to use, the if function or a combinations of format and replace functions? |
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Sun Jul 18, 2004 2:35 am |
How do you define better? The %if function is shorter, easier to read, and requires less processing.
A function is a function. If you don't mind using %format and %replace, there's no reason you should object to %if. |
|
_________________ LightBulb
Senior member
Most scripts in this forum are written for Command Line entry.
Don't even open the Settings Editor unless its use is specified or obvious. |
|
|
|
|
|