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!



_______________________________________________
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