Saturday, August 04, 2007

For FoxPro Geeks Only

I couldn't find any good replacements in Visual FoxPro for the Visual Basic functions IsDate and IsDateTime, so I created my own. I submit them here in hopes that some VFP programmer can pull them up in a Google search and get some use out of them:


************************************************************************
FUNCTION IsDateTime(sString)
************************************************************************
   RETURN IIF("/  /" $ TTOC(CTOT(sString)), .F., .T.)
ENDFUNC

************************************************************************
FUNCTION IsDate(sString)
************************************************************************
   RETURN IIF("/  /" $ DTOC(CTOD(sString)), .F., .T.)
ENDFUNC

12 comments:

Overdroid said...

FUNCTION IsNerd(PotentialNERD)

IF
UnderstandCODE(PotentialNERD)=1
OR
CollectCOMICS(PotentialNERD)=1
OR
PlayedRPGS(PotentialNERD)=1
THEN
NerdTRUE=1
ELSE
NerdTRUE=0
ENDIF

RETURN (NerdTRUE)

ENDFUNC

Don Snabulus said...

Code:

SET PROCEDURE TO OVERDROID ADDITIVE

SnabulusArray = ARRAY("OverDroid","Snabulus","MoodyMinstrel",;
        "Pandabonium","Ladybug","DewKid",;
        "InfoGeek","SwineBread","DeanWormer")

FOR Counter = 1 TO ALEN(SnabulusArray)

    IF IsNerd(SnabulusArray[Counter]) THEN
        ? SnabulusArray[Counter] "? Yep. A Nerd."
    ELSE
        ? SnabulusArray[Counter] "? Not a Nerd."
    ENDIF

NEXT

? "Sorry if I missed your name. You are a nerd if you are reading this."

Program Execution:

OverDroid? Yep. A Nerd.
Snabulus? Yep. A Nerd.
MoodyMinstrel? Yep. A Nerd.
Pandabonium? Yep. A Nerd.
Ladybug? Yep. A Nerd.
DewKid? Yep. A Nerd.
InfoGeek? Yep. A Nerd.
SwineBread? Yep. A Nerd.
DeanWormer? Yep. A Nerd.
Sorry if I missed your name. You are a nerd if you are reading this.

Pa've said...

I'll just whip out my nifty pocket protector, I have a different colored pen for each day of the week.

Pandabonium said...

As Agent 86 would say, "and loving it!"

Don Snabulus said...

Enhancement Request

Add Pa've to the SnabulusArray.

Don Snabulus said...

PB,

KAOS was in no way resposible for this code. for this code. for this code.

Tod McKenna said...

For Strings, you could also try:

RETURN LIKE("*/*/*",sString)
RETURN (YEAR(CTOD(sString)) > 0 )

Also, you could use TYPE and VARTYPE to check if a variable contains a date type (but this method doesn't work with strings).

Don Snabulus said...

Tod,

Those are great and look like they probably run faster than mine as well.

Also, I really like your blog. I might have to add that to my must read list.

Thanks.

Dean Wormer said...

I would consider you guys more geeks than nerds. Maybe a mix of both.

"Neeks?" "Gerds?"

The Moody Minstrel said...

Gosh, that's really boss!

Overdroid said...

Wormer. You would know.

Momo the Wonder Dog said...

I always thought of myself more as Tibetan or Chinese rather than Geek or Roman.