Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Getting a date from .txt file or variable
Message
From
09/07/2008 02:45:07
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
Miscellaneous
Thread ID:
01329441
Message ID:
01329911
Views:
11
Hi Moises,

I wrote about a similar problem in my blog, a few weeks ago, and wOOdy reminded me of solving such a problem with regular expressions. REs will do for you, too. For simply checking if the string starts with 2 digits, a slash, 2 digits, a slash, 4 digits you could use something like this:
SET CLASSLIB TO HOME()+ [ffc\_regexp.vcx]
oexp = CREATEOBJECT([_regexp])
oexp.clear
oexp.pattern = "^\d{2}/\d{2}/\d{4}"
* displays 0
?oexp.execute("04.07.2008 1054AC PRESIDENTE EPITACIO - PRESIDENTE EPITACIO/SPConferi")
* displays 1 = valid string
?oexp.execute("04/07/2008 1054AC PRESIDENTE EPITACIO - PRESIDENTE EPITACIO/SPConferi")
* displays 0
?oexp.execute("-04/07/2008- 1054AC PRESIDENTE EPITACIO - PRESIDENTE EPITACIO/SPConferi")
* displays 0
?oexp.execute("04/07/08 1054AC PRESIDENTE EPITACIO - PRESIDENTE EPITACIO/SPConferi")
>The date is in DD/MM/YY format as text below
>
>I already have the line number
>
>I was thinking about something as:
>
>If line contains "2008" or "2009" or "2010", get the the year
>and also contents at its left side and then convert it to date with ctod ()
>
>Can anybody help me with this line, or is there a more smart solution ?
>
>Thanks
>
>
>
>piece of TXT file
>
>**********************************
>
>04/07/2008 10:54AC PRESIDENTE EPITACIO - PRESIDENTE EPITACIO/SPConferido
>
>******************************************************************************
Best Regards
-Tom

Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it.

Oh, and BTW: 010101100100011001010000011110000101001001101111011000110110101101110011
Previous
Reply
Map
View

Click here to load this message in the networking platform