Author |
|
ginigma Senior Member
Joined: June 18 2006 Location: United States
Online Status: Offline Posts: 127
|
Posted: February 13 2008 at 22:00 | IP Logged
|
|
|
I'm using month (today()) which returns "2" for this month. How can I get it to return "02", meaning I always want 2 chars returned, so if the month is < 10, pad it with a "0"?
__________________ Insteon (40 devices) ^ PowerHome (435 links) ^ Logitech Harmony 880
|
Back to Top |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: February 13 2008 at 22:24 | IP Logged
|
|
|
First, be careful. Month returns a number, not a string. Since you want a leading zero, this is a string...
Code:
if( month(today())<9, string( month(today()), "00"), string(month(today())) ) |
|
|
|
Back to Top |
|
|
JaredM Newbie
Joined: November 04 2007
Online Status: Offline Posts: 36
|
Posted: February 13 2008 at 22:25 | IP Logged
|
|
|
or just
Code:
string(month(today()),"00") |
|
|
will work for single and two-digit months.
Edited by JaredM - February 13 2008 at 22:26
|
Back to Top |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: February 13 2008 at 22:49 | IP Logged
|
|
|
Well, sure, but mine looks more complicated!
|
Back to Top |
|
|
ginigma Senior Member
Joined: June 18 2006 Location: United States
Online Status: Offline Posts: 127
|
Posted: February 15 2008 at 00:01 | IP Logged
|
|
|
Ok Tony, I'll give you a chance to redeem yourself
Now it's the ph_run command.
This
Code:
ph_run ("dir > c:\temp\mmm") |
|
|
returns -1, but I can't figure out the error. Is it taking the greater than sign literally instead of redirection?
Code:
ph_run ("dir " + char (62) + " c:\temp\mmm") |
|
|
returns -1 also.
Thoughts?
__________________ Insteon (40 devices) ^ PowerHome (435 links) ^ Logitech Harmony 880
|
Back to Top |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: February 15 2008 at 07:07 | IP Logged
|
|
|
Heh. Here you go...
Code:
ph_run('cmd.exe /c ~"dir > "c:\dir.txt"~"') |
|
|
|
Back to Top |
|
|
ginigma Senior Member
Joined: June 18 2006 Location: United States
Online Status: Offline Posts: 127
|
Posted: February 15 2008 at 15:24 | IP Logged
|
|
|
You Sir, are a PowerHome God!
Now, for bonus points: Which is more efficient in a macro: the ph_run formula or Launch App command?
__________________ Insteon (40 devices) ^ PowerHome (435 links) ^ Logitech Harmony 880
|
Back to Top |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: February 15 2008 at 16:32 | IP Logged
|
|
|
I would simply say that, with the formula, you'll have a return code that you can do something with.
|
Back to Top |
|
|