Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Need assistance with 'field validation'
Message
 
À
02/03/2003 10:41:21
Mike Sue-Ping
Cambridge, Ontario, Canada
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00759567
Message ID:
00760765
Vues:
11
Mike,

I suppose you could create a method that accepts a parameter, the field, and then DO CASE would make more sense. Each CASE could be for the individual fields. This would be less messy. As for whether it's common, every programmer has his own style and what is common for one may not be for another. That is one of the great things about FoxPro, and programming in general. There are always several ways to accomplish your goal. This is where the individual's style shows up. Of course, there is usually one way that is the most efficient or the cleanest way. That, sometimes, is open to interpretation, and sometimes is just fact.

If possible, I would try for the parameter approach. I think that is probably the most common way to deal with this type of requirement. A CASE statement is always easier to read and follow than a bunch of IF statements when trying to undestand someone's code. Even if you wrote the code yourself, two years from now, you may find it difficult to figure out what you were trying to accomplish. Using comments and using the most straightforward approach are the two best ways to make that task easier. Efficiency is a great byproduct.

Dana

>Dana,
>
>Of course. You're correct in that DO CASE... is not what I'd need and several IF statements would be required. Anyway, if there were multiple fields that needed validating, is it recommended or common to create "large" IF statements within the validation rule?
>
>Mike
>
>>Mike,
>>
>>Unless only one CASE is ever going to be true, using DO CASE would not help you. For example, if both SomeCheckHere and AnotherCheckHere would return true, the CASE would fail you, because the first one encountered to be TRUE would fire, then the program execution would continue outside of the CASE. Because of this, you will need to make separate IF...ELSE...ENDIF statements for each field validation in this method. This way each is independent of the other and all of them will be checked.
>>
>>Dana
>>
>>>Hi Gregory.
>>>
>>>I guess my question now is, do I have to put every "case" into this record validation rule? I mean, if I have several fields that need some sort of validating, do I then need to build a case for each and every one of them and expand on the example you provided? Something like,
>>>
>>>do case
>>>case SomecheckHere
>>> repl field with SomeCalculatedValue
>>>
>>>case AnotherCheckHere
>>> repl field2 with SomeOtherCalculatedValue
>>>.
>>>.
>>>.
>>>case area <> Length * Width
>>> repl area with Length * Width
>>>.
>>>.
>>>.
>>>
>>>endcase
>>>
>>>TIA
>>>
>>>Mike
>>>
>>>>Mike,
>>>>
>>>>Put the code in the Record Validation rule
>>>>
>>>>do case
>>>>case area <> Length * Width
>>>>  repl  area with Length * Width
>>>>endcase
>>>>
Where's the damned Any Key?...too late
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform