system
April 2, 2009, 2:41pm
1
(imported topic written by nipperjones91)
hey, I’m trying to create a property to capture line of a file but only on a specific OS type e.g windows (basically to stop all linux machines to present an error)
i’m not 100% sure how to achieve this but started out with this (which doesnt work)
if (name of operating system as lowercase starts with “win”) then (lines of file “test.txt” of folder “c:/”) else false
any help on this would be great
BenKus
April 3, 2009, 6:06am
2
(imported comment written by BenKus)
Hi nipperjones,
You are very close… If you run this in QnA, you get the error:
q:if (name of operating system as lowercase starts with “win”) then (lines of file “test.txt” of folder “c:”) else false
E: Incompatible types.
“Incompatible types” in this case means that one branch of the “if” is returning a line of file and the other is returning a boolean.
It should be easy to fix by replacing “false” with the string “n/a”:
q:if (name of operating system as lowercase starts with “win”) then (lines of file “test.txt” of folder “c:”) else “n/a”
But… perhaps a better method would be to create an analysis and the analysis relevance would be:
(name of operating system as lowercase starts with “win”) AND (exists file “C:\test.txt”)
And the property would be:
lines of file “C:\test.txt”
And this would work fine because the relevance of the Analysis would “guard” against running the property on machines without the file.
Ben
system
April 3, 2009, 11:31am
3
(imported comment written by nipperjones91)
cool thanks Ben