MacOS and Windows, I don’t know. I do know that these OSes present ports for devices but not apps.
In Linux, ALSA maintains the connections. So, to get the current status, ask ALSA: "aconnect -l".unixCmdGetStdOut and parse the string. (“Why isn’t there a more convenient way?” I guess because nobody needed it. As a funny aside, this was removed from MIDIIn help, but James McCartney’s original help file for MIDIIn introduced the class only with “A popular 80s technology.”)
Alternately, is there any reason why SC should prohibit user-defined errors? It would be unnecessary (and awful) to impose an artificial limitation here.
And if so, how would that be done? For instance, SC has no mechanism to prohibit subclassing, so at minimum, you can always have MyNewErrorType : Error { ... } and there’s nothing SC can do to stop you.
In any case, the Error help file (for the class Error) does provide an even simpler example:
Error("File % could not be opened.".format(path)).throw;
Actually the linked bit on error handling has a similar example, right at the top of that section: Error("This is a basic error.").throw;
Already stated: “you can always have MyNewErrorType : Error { ... }”
MyNewError : Error {
*new { | /* whatever arguments you need */
... populate instance variables ...
}
errorString {
^"This is the bad thing that happened..."
}
}
^^ where the above is just following models in the class library. The error class definitions are not complex – pretty easy to suss out how to add more.