IF Statement

A

AA2e72E

Depending on whether a variable length field (1 to 6 characters) contains the
letter L, I want to be able to insert different text. I tried:

{ IF CODE = "*L*" "HAS L" "DOES NOT HAVE L" }

Why does this not work?
 
G

Graham Mayor

It doesn't work because the field does not accept wildcards.
Depending on whether a variable length field (1 to 6 characters)
contains the letter L, I want to be able to insert different text. I
tried:

{ IF CODE = "*L*" "HAS L" "DOES NOT HAVE L" }

Why does this not work?

CODE is a field and and it appears that you can only have one wildcard
asterisk in the string. You can have an asterisk and more than one question
mark to represent single characters. Thus if Code was 'yellow' "??l*" would
work, "*w" would work , "y*" would work "y*w" would work, but "*l*" doesn't
work.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
A

AA2e72E

Thanks Graham.

I can get round with this:

{IF CODE = "L*" "HAS L" {IF CODE = "?L*" "HAS L" {IF CODE ="??L*" "HAS L" ….
More IF statements }}}

This gets very messy.

Is there any way I can use INSTR?
 
M

macropod

Hi,

Testing whether a string contains a specified sub-string means testing for
the sub-string at each position in the string. AFAIK there is no way around
testing for the sub-string at specified positions. You could reduce the
number of nested IF tests by using (nested) OR tests, but I doubt that would
achieve much. Alternatively, you could sum a series of IF test results and
avoid nesting the IF tests altogether, as in:
{={IF CODE = "L*" 1 0}+{IF CODE = "?L*" 1 0}+{IF CODE = "??L*" 1 0}+{IF CODE
= "???L*" 1 0}+{IF CODE = "????L*" 1 0}+{IF CODE = "?????L*" 1 0}}

Cheers
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top