Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Jun Tangunan
  Where is Jun Tangunan?
 Cabanatuan
 Philippines
 Jun Tangunan
 To: Samir H.
  Where is Samir H.?
 Yogyakarta
 Indonesia
 Samir H.
 Tags
Subject: RE: rename table if
Thread ID: 289214 Message ID: 289262 # Views: 27 # Ratings: 0
Version: Visual FoxPro 9 Category: Forms
Date: Thursday, December 30, 2010 5:46:44 AM         
   


> >
> >
> > I saw that you already got what you need but I just want to add some more:
> >
> > a. The easiest way to combine the dates to a character is by using DTOS() like this:
> >
file_to_copy = "Month"+dtos(date())+".dbf"

> >
> > Although maybe you really wanted your format, so a cleaner code would be to use TRANSFORM():
> >
file_to_copy= "month"+TRANSFORM(MONTH(DATE()))+TRANSFORM(YEAR(DATE()))+".dbf"

> >
> >
> > b. IMHO, it is better to add the flag 1 on FILE():
> >
IF FILE(file_to_copy)      &&  will return false if file is marked as system or hidden
> > IF FILE(file_to_copy,1)    &&  will return true regardless if file is marked as system or hidden
> > 
> > 

> > That goes the same with DIRECTORY(). A numeric flag of 1 is better to ensure that it will include in the checking the marked hidden or system ones.
> >
> >
> > http://www.junblogs.com/
> > http://weblogs.foxite.com/sandstorm36/default.aspx
> > http://www.coderisland.com/forum/viewforum.php?f=10
>
>
> Hi Jun
> Why do you think transform() is cleaner? I always use ltrim(str()) for numerics, it is faster...
>
file_to_copy= "month"+ltrim(str(month(date())))+ltrim(str(year(date())))+".dbf"
> 
> file_to_copy= "month"+TRANSFORM(MONTH(DATE()))+TRANSFORM(YEAR(DATE()))+".dbf"

>
>
> Regards
> Samir


I mean "visually" and programmatically cleaner. It is easier to read as only one function is used as compared to TRIM() combined with STR(). Transform() itself performs both trimming and conversion to string in one go.

Although there are certain cases where TRIM() and STR() is the way to go instead of TRANSFORM(), I don't think that the above is among the "certain" cases.


http://www.junblogs.com/
http://weblogs.foxite.com/sandstorm36/default.aspx
http://www.coderisland.com/forum/viewforum.php?f=10

ENTIRE THREAD

rename table if Posted by mohammed qasem @ 12/29/2010 3:15:43 PM
RE: rename table if Posted by Ony Too @ 12/29/2010 3:35:29 PM
RE: rename table if Posted by Samir H. @ 12/29/2010 3:35:53 PM
RE: rename table if Posted by mohammed qasem @ 12/29/2010 3:47:13 PM
RE: rename table if Posted by Jun Tangunan @ 12/30/2010 5:22:29 AM
RE: rename table if Posted by Samir H. @ 12/30/2010 5:31:06 AM
RE: rename table if Posted by Jun Tangunan @ 12/30/2010 5:46:44 AM
RE: rename table if Posted by Ony Too @ 12/30/2010 10:56:48 AM
RE: rename table if Posted by Samir H. @ 12/30/2010 11:47:25 AM