Single value from a multiple result

(imported topic written by CCupit91)

Simple enough problem but my brain cant get round it, I’m trying to return a single value for a retrieved property, but some are returning as multiple results, all I want to do is to return the first (whatever it is) value from the retrieved property.

Thanks,

Chris

(imported comment written by BenKus)

Usually this is not a good idea because you can’t be sure of what order the results are returned in… So you might get random orderings… but if you have a list of strings, you can prepend: ‘preceding text of first “;;;” of concatenation “;;;” of’ and it should return the first entry:

Q: preceding text of first “;;;” of concatenation “;;;” of (“a”;“b”;“c”)

A: a

Again, I advise you to try to find better ways to do this…

Ben

(imported comment written by CCupit91)

Ok am not having much success with this, I tried using concatenation but when It runs I think it encounters issues with the text processing when it comes to a value that does not have multiple values.

What I’m trying to do is use the CPU Speed In MHZ property which returns the maximum CPU speeds for the computer (as opposed to CPU which returns the current CPU speed and returns incorrect values for laptops that have stepped down). This will be used to report on all machines with a CPU speed under 1000mhz.

However CPU Speed in MHz may return several values depending on the number of processors in the machine, i tried doing

preceding text of first “;” of (concatenation “;” of values of (results (it, bes property “CPU Speed in MHZ”))) of bes computers

however it fails (I think) on machines that dont have 2 processors and therefore a ; does not get concatenated in.

All the values returned are the same ie.

using (concatenation “;” of values of (results (it, bes property “CPU Speed in MHZ”))) of bes computers

Example

1399;1399

1400

600

1200;1200

Perhaps I’m heading in the wrong direction on this but guidance would be appreciated.

(imported comment written by Lee Wei)

Try this?

(if (it contains “;”) then (preceding text of first “;” of it) else it) of (concatenation “;” of values of (results (it, bes property “CPU Speed in MHZ”))) of bes computers

(imported comment written by BenKus)

Lee Wei’s method will work, or you could try always adding the delimiter at the end:

q: preceding text of first “;;;” of ((concatenation “;;;” of (“a”;“b”;“c”)) & “;;;”)
A: a

q: preceding text of first “;;;” of ((concatenation “;;;” of (“a”)) & “;;;”)
A: a

Ben