Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
PowerHome Programming
 PowerHome Messageboard : PowerHome Programming
Subject Topic: month() function Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
ginigma
Senior Member
Senior Member


Joined: June 18 2006
Location: United States
Online Status: Offline
Posts: 127
Posted: February 13 2008 at 22:00 | IP Logged Quote ginigma

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 View ginigma's Profile Search for other posts by ginigma Visit ginigma's Homepage
 
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: February 13 2008 at 22:24 | IP Logged Quote TonyNo

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 View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 
JaredM
Newbie
Newbie


Joined: November 04 2007
Online Status: Offline
Posts: 36
Posted: February 13 2008 at 22:25 | IP Logged Quote JaredM

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 View JaredM's Profile Search for other posts by JaredM
 
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: February 13 2008 at 22:49 | IP Logged Quote TonyNo

Well, sure, but mine looks more complicated!
Back to Top View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 
ginigma
Senior Member
Senior Member


Joined: June 18 2006
Location: United States
Online Status: Offline
Posts: 127
Posted: February 15 2008 at 00:01 | IP Logged Quote ginigma

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 View ginigma's Profile Search for other posts by ginigma Visit ginigma's Homepage
 
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: February 15 2008 at 07:07 | IP Logged Quote TonyNo

Heh. Here you go...

Code:
ph_run('cmd.exe /c ~"dir > "c:\dir.txt"~"')
Back to Top View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 
ginigma
Senior Member
Senior Member


Joined: June 18 2006
Location: United States
Online Status: Offline
Posts: 127
Posted: February 15 2008 at 15:24 | IP Logged Quote ginigma

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 View ginigma's Profile Search for other posts by ginigma Visit ginigma's Homepage
 
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: February 15 2008 at 16:32 | IP Logged Quote TonyNo

I would simply say that, with the formula, you'll have a return code that you can do something with.

Back to Top View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum