MIDIPortName

Returns the MIDI port name for the specified port number. When MIDIGetEvent() matches a "Port #" type of event, it sets MIDIEvent.!Data1 to the port number. MIDIPortName() can be used to retrieve the matching name.

Synopsis

name = MIDIPortName(number, option)

Args

option determines which type of MIDI port is being queried. It must be one of the following:

Option Meaning
'I' (Input) MIDI Input port
'O' (Output) MIDI Output port

If omitted, option defaults to 'O'.

number is the port number for which the name is to be returned. If omitted, then a count of the number of input or output ports (depending upon option) is returned.

If both number and option are omitted, then the currently selected event's port name is returned.

Returns

The port name or a count of ports, if successful. An empty string if an error (or there is no such port number on the system).

Notes

If you set the MidiErr variable to raise a condition, and you omit number and option, then that condition is raised if there is no currently selected event.

If you pass a value for option which is not one of the allowable ones, then a REXX SYNTAX condition is raised. CONDITION('E') returns error number 40.28 and CONDITION('D') returns the message MIDIPortName argument 2, option must start with one of "<options>"; found "<badchoice>" where <options> are the allowable choices and <badchoice> is what you erroneously passed.

Examples

/* Get the name corresponding to a port number of 0 */
name = MIDIPortName(0)
IF name \== "" THEN SAY 'port name =' name

/* Query the current event's port name */
name = MIDIPortName()
IF name \== "" THEN SAY 'port name =' name

/* Display the names of all input ports on the system */
num = MIDIPortName(, 'I')
DO i = 1 TO num
  name = MIDIPortName(i - 1, 'I')
  IF name \== "" THEN SAY name
END