Retrieving values from unconnected parameters

I want to read the name and value of all boolean toggles in a script and output it as a text file.
How do I retrieve the value of a component?
I have made an ugly hack using InstanceDescription, but can I retrieve the value in a better way?

I have the code:

private void RunScript(bool Run, ref object status)
{
List outputText = new List();
foreach(IGH_ActiveObject activeObject in GrasshopperDocument.ActiveObjects()){
if(activeObject.Name == “Boolean Toggle”){*
string str = activeObject.NickName.ToString() + " : " + activeObject.InstanceDescription.ToString();
outputText.Add(str);
}
}
status = outputText;
}

And get the output

myBooleanToggle : One locally defined value…
True

myOtherBooleanToggle : One locally defined value…
False

The output is want is:
myBooleanToggle : True
myOtherBooleanToggle : False

Cast your “activeObject” to the proper type “Grasshopper.Kernel.Special.GH_BooleanToggle” so you can use the .Value property:

  private void RunScript(bool Run, ref object status)
  {
    List<string> outputText = new List<string>();
    foreach(IGH_ActiveObject activeObject in GrasshopperDocument.ActiveObjects()){
      if(activeObject.Name == "Boolean Toggle"){
        Grasshopper.Kernel.Special.GH_BooleanToggle toggle = (Grasshopper.Kernel.Special.GH_BooleanToggle) activeObject;
        string str = toggle.NickName + " : " + toggle.Value.ToString();
        outputText.Add(str);
      }
    }
    status = outputText;
  }

Works beautifully, thanks