Is there an easier way to pull the nth value of a multiple results relevance?
Example… If I wanted the 1st value of regapps, I’d go like this…
The first value…
preceding text of first “/” of concatenation of (it & “/”) of names of regapps
The second value…
preceding text of first “/” of following text of first “/” of concatenation of (it & “/”) of names of regapps
The third value…
preceding text of first “/” of following text of first “/” of following text of first “/” of concatenation of (it & “/”) of names of regapps
Do I really need to concatenate to split it apart again? I’d rather do something like “index 3 of names of regapps” or “value 3 of names of regapps” to get the third value.
I think there is going to be a better way to do this using the ‘whose/it’ clause. With multi-valued results you aren’t guaranteed an ordering to the results so there isn’t an index inspector. Given this, your query could return invalid results if the regapps order did change or maybe a new regapp got installed. Instead, you can do something like this to filter the regapps down to the one you are interested in:
Q: regapps whose (name of it = "BESClient.exe")
A: "BESClient.exe" "6.0.20.9" "BigFix BESClient Application" "6.0.20.9" "BigFix Inc."
Q: (name of it & " - " & (if (exists version of it) then (version of it as string) else ("No Version"))) of regapps whose (name of it as lowercase contains "bes")
A: BESAdmin.exe - 6.0.20.9
A: BESClient.exe - 6.0.20.9
A: BESConsole.exe - 6.0.21.5
A: BESSimulator.exe - 1.5.1.20
Q: name of regapps "BESClient.exe"
A: BESClient.exe
The relevance language does not guarantee any result order. In practice most queries will return results in the same order, but you should not rely on that behavior. This looks to be particularly true with your query since it returns regapps and the set of regapps on each machines is very likely to be different and unpredictable.
I would try to write you query to narrow down the results a little more using a ‘whose’ clause. Perhaps you can share your end goal with us so we can offer suggestions?
My earlier post was more of an “can you” than a “I need to”. I do have a situation now where order is specific.
I want to make sure that the DNS of the PC’s adapter is in a specific order. I can check to make sure all 3 are defined, but the order is important. Based on what you said, I guess that this can’t be guarenteed to be retured in the order defined in TCP/IP…
concatenation “,” of (address of it as string) of dns servers of adapters of network
I ended up going directly to the registry for this one in the end, which I needed to be anyhow to write the correct DNS values back.
Curious as to why you are needing them in a certain order. I had to write relevance to report back all the network adapters and the IP/DNS/SUBNET/GW information specific to that adapter. If you are trying to do something like that I could show you what I did. Cheers.
Our field locations are connected to our network through one of several different locations. Each of these main locations has several DNS servers. So depending on your field site, you DNS order will be different. We want the first 2 DNS servers to be at the location you come through, and the 3rd DNS server should be one of the alternate sites.
So the ordering is specific to our standard, so I needed to know that the DNS servers are defined as A,B,C and not C,B,A.
That’s why I ended up getting it directly from the registry.