In my own case I was talking to a remote Atmel device, i realised some systems may have more than a single port and different com numbers. The resolution was to mod the atmel code to report to a handshake request and cycle the open com upwards to 10 in a simple repeat until open, then send the handshake, wait for reply, if not continue.
Solved the problem adequately.
you can wrap the relevant info in a DATA / READ arrangement and replace com% = OPENUP("COM1:9600,N,8,1") with
DATA x, "COM1:9600,N,8,1", and so on
timeout% + = 1
READ com$:com% = OPENUP("com$")
UNTIL com%>0 OR timeout%=x
x being the number of $ in the line, so if timeout%=x and com%=0 didn't and can't open, if com% is true then timeout% carries the comport physical number.