If then else "it" reference error

(imported topic written by IanR2974)

Hello,

I am trying to tidy up my “if then else” relevance (the second Q:) by using it to reference 2 repeated strings, however when i use “it” it will fail when it can’t find the file or the line.

Below are the results when i remove the line i am looking for:

Q: (IF (exists it) THEN ((if (exists it) then (exists (it whose (it does not contain “disabled”))) else FALSE) of line containing “svc:/application/graphical-login/cde-login” of it) ELSE TRUE) of file “C:\Test\testfile”

E: Singular expression refers to nonexistent object.

Q: (IF (exists file “C:\Test\testfile”) THEN (if (exists line containing “svc:/application/graphical-login/cde-login” of file “C:\Test\testfile”) then (exists (line containing “svc:/application/graphical-login/cde-login” of file “C:\Test\testfile”) whose (it does not contain “disabled”)) else FALSE) ELSE TRUE)

A: False

T: 0.632 ms

I: singular boolean

Any help here would be appreciated as the real pathnames are a lot longer.

thanks Ian

(imported comment written by NoahSalzman)

Could you explain what you are trying to accomplish? It’s not clear from the examples.

Does the following syntax help?

q: (exists line containing “svc:/application/graphical-login/cde-login” of it and not exists line containing “disabled” of it) of file “c:\test\testfile”

A: True

q: (exists line containing “svc:/application/graphical-login/cde-login” of it and not exists line containing “login1” of it) of file “c:\test\testfile”

A: False

q: lines of file “c:\test\testfile”

A: svc:/application/graphical-login/cde-login

A: svc:/application/graphical-login/cde-login1

A: svc:/application/graphical-login/cde-login2

(imported comment written by IanR2974)

Hi,

Apologies i wasnt clear. What i am trying to achieve is 3 things:

If the file “C:\Test\testfile” does not exist the relevance should return true.

if the line “svc:/application/graphical-login/cde-login” does not exist it should return false

if the line does exist it should contain “disabled” or should return true.

The second relevance i posted does work, however the first one doesn’t work as it doesnt seem to pick up the “it” refrenences which i was trying to use to tidy the relevance up.

I hope this makes what i am trying to do more clearer.

(imported comment written by NoahSalzman)

This should work:

exists line whose (it contains “svc:/application/graphical-login/cde-login” and it does not contain “disabled”) of file “c:\test\testfile” | true

(imported comment written by IanR2974)

Thanks Noah

This works a treat. :slight_smile: