Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Filter incorrect coded values
Message
From
31/12/2001 11:18:46
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00599378
Message ID:
00599394
Views:
11
This message has been marked as a message which has helped to the initial question of the thread.
>>>One more complication for Amenities field - this field is 10 char long and it's a concatenation of codes, e.g. ABCUD, where each letter is a code. How would we filter those contain incorrect codes?
>>
>>For this one, I don't know a simpler alternative than to use a FOR loop.
>>
>>
>>* Function for validation)
>>local i
>>for i = 1 to len(amenities)
>>  if not substr(Amenities, i, 1) $ "ABCDE" && or other valid codes
>>    return .F.
>>  endif
>>next
>>
>>
>>Hilmar.
>
>No, I need one SET FILTER TO command, so loop would not work. I guess, I can put all codes in a thisform.cAmenities string, then something using chrtran. However, even this idea has some problems, because Set Filter is another form, which would not now about main form...

I meant setting the filter to a UDF. Like this:
SET FILTER TO OnlyContainsValidCodes(Amenities, "ABCDE")
* or, to show invalid fields:
* set filter to not OnlyContainsValidCodes(Amenities, "ABCDE")
BROWSE
* or perhaps: REPORT FORM


FUNCTION OnlyContainsValidCodes(tcExpression, tcCodes)
local i
for i = 1 to len(tcExpression)
  if not substr(tcExpression, i, 1) $ tcCodes
    return .F.
  endif
next
ENDFUNC
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Previous
Reply
Map
View

Click here to load this message in the networking platform