Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: onytoo
  Where is onytoo?
 Padang
 Indonesia
 onytoo
 To: Samir H.
  Where is Samir H.?
 Yogyakarta
 Indonesia
 Samir H.
 Tags
Subject: RE: rename table if
Thread ID: 289214 Message ID: 289290 # Views: 27 # Ratings: 1
Version: Visual FoxPro 9 Category: Forms
Date: Thursday, December 30, 2010 10:56:48 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

Hi, Sammy..

TRANSFORM is more simple and you not need to worried about any data type to convert,
eExpression parameter can use directly with numeric, string, logical, date, etc.

IMHO, if TRANSFORM was used without cFormatCodes parameter, it same as ALLTRIM(STR().
And yes XTRIM(STR()) more faster than TRANSFORM().


Regards,
Onytoo

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