Allowing Multiple Results from a IF/THEN statement

(imported topic written by Matt.Johnson)

Hello all,

I am building an analyses to generate a result from a string of text in a .txt files. I can do the single variable style of this:

Q:IF exist lines whose (it as lowercase contains “TheTextIWant” as lowercase of file “C:\folder” THEN “Bazinga” ELSE “N/A”

This kind formatting works for me, but I need to extend that, and each format I try fails. How do I have it look for multiple values?

Such as:

Q:IF exist lines whose (it as lowercase contains “TheTextIWant” as lowercase of file “C:\folder” THEN “Bazinga” ELSE IF exist lines whose (it as lowercase contains “SomeOtherText” as lowercase) of file “C:\folder” THEN “BigFix Rocks” ELSE IF exist lines whose (it as lowercase contains “YetOtherText” as lowercase) of file “C:\folder” THEN “It’s Called Tivoli” ELSE “N/A”

I am reviewing my documentation, but I am struggling to get the right formatting here. Thanks for any assistance!!

(imported comment written by IanR2974)

Hi Matt,

try this

IF exist lines whose (it as lowercase contains “TheTextIWant” as lowercase) of file “C:\Test\test.txt” THEN “Bazinga” ELSE IF exist lines whose (it as lowercase contains “SomeOtherText” as lowercase) of file “C:\Test\test.txt” THEN “BigFix Rocks” ELSE IF exist lines whose (it as lowercase contains “YetOtherText” as lowercase) of file “C:\Test\test.txt” THEN “It’s Called Tivoli” ELSE “N/A”

(imported comment written by IanR2974)

Or to tidy it up a bit by just having one reference to the file use

(IF exist lines whose (it as lowercase contains “TheTextIWant” as lowercase) of it THEN “Bazinga” ELSE IF exist lines whose (it as lowercase contains “SomeOtherText” as lowercase) of it THEN “BigFix Rocks” ELSE IF exist lines whose (it as lowercase contains “YetOtherText” as lowercase) of it THEN “It’s Called Tivoli” ELSE “N/A”) of file “C:\Test\test.txt”

(imported comment written by Matt.Johnson)

Ian,

Thanks for the relevance. However, I am still having some issues. Even when the search string is present in the file, the result is the last ELSE (N/A) so it’s not detecting correctly. Let me give you a real-time example:

The text file reads:

ERROR: An error occurred (code 0x80070057):

The parameter is incorrect.

The line that should pick that up is:

(IF exist lines whose (it as lowercase contains “ERROR: An error occurred (code 0x8070057)” as lowercase) of it THEN “Needs Partition” ELSE IF exist lines whose (it as lowercase contains “Bazinga” as lowercase)

but yet it results with:

A: N/A

I tried it as admin, I even ran it through the system client, still the same result. Any thoughts?

Thanks,

Matt

(imported comment written by IanR2974)

Hello Matt,

you have missed a 0 in your relevance have pasted both below so you can easily see. As i didn’t see it at first either :slight_smile:

Text in file:
ERROR: An error occurred (code 0x80070057):

Relevance: “ERROR: An error occurred (code 0x8070057)”

(imported comment written by Matt.Johnson)

Ian - That worked great! Thank you.