Google

 COM_NUM()
 Gives the number of the highest available serial interface port

Syntax COM_NUM() --> nMaxCom Returns COM_NUM() returns the number of the highest available serial interface port. Description This function returns the number of the serial interface port available. This is not to say that a return value of 3 necessarily means that ports 1 through 3 are available; for example, COM2 could be missing. Whether or not a serial port can actually be used can be tested using the COM_OPEN() or COM_INIT() functions. Examples Determine the number of ports: ? COM_NUM() // e.g. 4

See Also: COM_OPEN()