I would do nothing ... No error checking ... Nothing.  If the user is so
impolite as to ignore the instructions for proper use, (s)he does not
deserve the courtesy of acknowledgement.  It's about time that we
started using functions in a gentrified manner.

On the other hand, you could check for errors and send an e-mail
notification to yourself advising of same.  Then contact the offender
and offer to repair his installation for a fat non-refundable fee. Then,
while making the repairs, inject some other low-level problem that will
necessitate a callback.  Prudent and imaginative use of this technique
could yield a vast array of emoluments, a la the auto repair industry.

HTH

HALinNY

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Kevin Cully
Sent: Monday, June 26, 2006 08:11
To: [email protected]
Subject: Strong parameter checking

I'm working on a class that I'm wanting to make Open Source and I'm
making functions/methods that take parameters.  This function could be
abused in ways that I have never anticipated.  Since VFP is loosely
typed, I'm wondering what checking I have to do on these parameters to
make sure that the parameter is provided, not .NULL. and of the type
expected?  Is this overkill?

FUNCTION MyFunction(tcSomething AS String) AS String
    LOCAL lcRetVal
    lcRetVal = []
    IF PCOUNT() = 1
       IF NOT ISNULL(tcSomething)
          IF VARTYPE(tcSomething) = "C"
             IF NOT EMPTY(tcSomething)
                lcRetVal = [My Function ] + tcSomething
             ENDIF
          ENDIF
       ENDIF
    ENDIF
    IF EMPTY(lcRetVal)
       =MESSAGEBOX("Your call to " + PROGRAM() + " is lacking." + ;
         "  Try again."
    ENDIF
RETURN lcRetVal
ENDFUNC

What's the most graceful way in VFP to accomplish this?  ASSERTS work in
development but what about data driven production systems?  There must
be a better way that I'm unaware of.

-- 

Kevin Cully
CULLY Technologies, LLC

Sponsor of Fox Forward 2006!



[excessive quoting removed by server]

_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to