Hi
I tend to use a DO CASE construct when I want to do something like this.
Function MyFunction (tcSomething)
Do Case
Case Pcount() <> 1
Case IsNull(tcSomething)
Case Not (Vartype(tcSomething) = "C")
Otherwise
*-- Everything is OK
EndCase
Regards
Dominic Burford BSc Hons MBCS CITP
Third Party Developer Program Senior Software Engineer
* Tel: +44 (0) 1536 495074
* [EMAIL PROTECTED]
"I conclude that there are two ways of constructing a software design:
One way is to make it so simple there are obviously no deficiencies, and
the other way is to make it so complicated that there are no obvious
deficiencies." -- Tony Hoare, Turing Award Lecture 1980
-----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!
_______________________________________________
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.
______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________
______________________________________________________________________
Pegasus Software Limited is a member of the Systems Union Group plc
Registered Office: Systems Union House, 1 Lakeside Road, Aerospace Centre,
Farnborough, Hampshire GU14 6XP Registered No: 1601542
This e-mail is from Pegasus Software Limited. The e-mail and any files
transmitted with it are confidential and intended solely for the use of the
individual or entity to whom it is addressed. If you have received this e-mail
in error you must not copy, distribute or take any action in reliance on it.
Please notify the sender by e-mail or telephone.
Pegasus Software Limited utilises an anti-virus system and therefore any files
sent via e-mail will have been checked for known viruses. You are however
advised to run your own virus check before opening any attachments received as
Pegasus Software Limited will not in any event accept any liability whatsoever
once an e-mail and/or any attachment is received.
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________
_______________________________________________
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.