Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Parameters and what to check
Message
From
18/10/2007 09:33:00
 
 
To
18/10/2007 09:24:48
Mike Yearwood
Toronto, Ontario, Canada
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 8 SP1
Miscellaneous
Thread ID:
01261696
Message ID:
01261816
Views:
24
You know what, Mike - whenever I stick my neck out you jump up and sink your teeth into it :-)

True, I thought there was something about PCOUNT() that looked funny. I've always used PARA(). Apart from its being reset when another proc/func/udf is called I swear I've seen it losing its value after a few lines of code into the proc. Maybe that's been when a system func has been used - I can't remember - maybe even back in VFP3 days. I just know I've always evaluated it 1st thing on enetering a proc/func, cos this bit me years ago, so it's not been an issue to bother me since.

>The Parameters() function is the one that resets. PCOUNT is preferable because it doesn't do that. You're right not to call the function multiple times for performance.
>
>>Tore
>>
>>I haven't come across this problem often but I'm pretty sure that sometime in the past, once processing had started in a parameterised proc/func, PCOUNT() had lost its result and could not be relied on. For this reason, if I'm testing for the no. of params I always store PCOUNT() toi a var first thing.
>>
>>Now I don't know whether this has been fixed with later SPs, or indeed later versions, but just a precaution I take. Besides, the purist in me doesn't like calling a func several times
>>
>>>
>>>lparameters cPar1, cPar2,cPar3
>>>do case
>>>  case pcount()<3
>>>    cPar3='mydefault3'
>>>  case pcount()<2
>>>    cPar2='mydefault2'
>>>endcase
>>>
>>>>Let's say I have a procedure that is expecting 3 parameters, but sometimes only 2. They should all be character. Is there a standard that others use that would run through some validations, checking type, pcount, stuff like that? Want to make the project I'm working on as tight and error free as possible. Here is an example:
>>>>
>>>>
>>>>******************************************************************************************************
>>>>FUNCTION Procedure_Locked
>>>>******************************************************************************************************
>>>>
>>>>	LPARAMETERS tcProcess, tcLockUnlock, tcUserID
>>>>
>>>>
- Whoever said that women are the weaker sex never tried to wrest the bedclothes off one in the middle of the night
- Worry is the interest you pay, in advance, for a loan that you may never need to take out.
Previous
Reply
Map
View

Click here to load this message in the networking platform