Hi guys,
I’ve had a look through the sample code and am a little less familiar with C# than with some other languages. I’m just looking for some very simple code to extract certain information from the API Explorer and output it into the log. I work best by looking at examples - But the code examples I’ve seen (the 0km autopilot and the miner) are either a little short or lacking from what I want.
So I’ve broken apart the 0km warper to a fairly simple script that loops every 4 seconds and invalidates the MemoryMeasurementParsed. I’ve kept Measurement, and am trying to follow the object down to the data I need.
Now in this case I’m simply looking to get the label text for all the entries inside the Probe Scanner window. Being familiar with Javascript, this is how I would lay it out based on what I see in the API Explorer:
var Measurement = Sanderling?.MemoryMeasurementParsed?.Value;
var temp = Measurement.WindowProbeScanner[0].ScanResultView.Entry; //This is the array containing the entires
for (var i = 0; i < temp.length; i++) {
Host.Log(temp[i].LabelText[2].Text); //Will simply output the text of each site
}
So the first error I get is trying to access [0] of the WindowProbeScanner array (is it actually an array? It acts like one in the API explorer). Apparently it’s actually an “IEnumerable” but I’m not sure how to access the data in that.
Apologies if this is a really stupid C# question, I’m not even sure what to Google since you seem to be using your own types and I’m really not sure where to go from here.
Thanks in advance.
Edit: Oh! I think I may have found it - The ElementAtOrDefault() function, and also I need to use ?. instead of … I’ll give that shot tomorrow when I get up.