Kevin,
If the wrong parameters are passed then immediately reformat the hard disk.
That way you will get very few repeat errors and the evidence of your
mischief will be completely erased. <BG> 


Dave Crozier
"A computer is a stupid machine with the ability to do incredibly smart
things, while computer programmers are smart people with the ability to do
incredibly stupid things. They are, in short, a perfect match"  - Bill
Bryson
 

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
Of Kevin Cully
Sent: 26 June 2006 13: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