using pipe in conditions

Walter Vaughan wvaughan at steelerubber.com
Wed Jan 31 04:30:52 PST 2007


Jeff Harrison wrote:
> --- Scott Nelson <scott at logicdatasystems.com> wrote:
>>Just wondering......
>>Why not as ' if: aa eq "a|b|c" '  - to shorten the
>>condition line, 
> Actually, the following is acceptable in filepro:
> if: "a|b|c" co aa
> 
> Now, it can get slightly more complicated if you are
> dealing with fields of different lengths, so you may
> want to modify this slightly as in:
> 
> if: "|a|b|c|" co ("|"{aa{"|")

Scott, I guess it's unfortunate that in this example most filePro developers use 
the pipe character as a field separator. It has no effect other than acting as a 
separating entity. Anything *houldn't* be in your data, is visible, and is below 
chr("128") are candidates for replacing the pipe in the above example. The 
presence of the pipe does not imply any type of "or-ing" condition.

if: "a|b|c" co aa
evalueates true if aa equals a "a" or a "b" or a "c" or a "|" or a "a|" or a 
"|b" or a "|c|" or a "b|c" or a "b|c|" ..... hopefully you get the idea.

Contains always confuses me. It does what it says. Its normal use is
[what you are searching in] co [what I am searching for] or
"something_long" contains "something_shorter up to something_long"

With if: "|a|b|c|" co ("|"{aa{"|")
what we do is wrap a characters around our testing variable in order to insure 
we match exactly what we are looking for. In this case the aa can only be a an 
"a" or a "b" or a "c". However the pipe has no magical powers. It could have 
been written just as easily as
if: "#a#b#c#" co ("#"{aa{"#") 'if pipes may appear but not #lbs or
if: "!a!b!c!" co ("!"{aa{"!") 'if pipes may appear but not !bangs or
if: "&a&b&c&" co ("&"{aa{"&") 'or want to use an ampersand

or probably at least 30 ways more...


More information about the Filepro-list mailing list