This is a great contribution to the GS community, thanks.

After tested it with your previous example code on my vista machine. I met two minor problems,

First, when port_open_read/write/readwrite my existing com port, it only suceeded once, after my exiting the script and re-run it again, the port_open_xxxx command seems not to work anymore. But when I close the SED then reopen the SED, load the script, run it. It works again. (and Yes, the first script run only)

Listed bellow is my modified script from your example,

Code:
#include <acknex.h>
#include <default.c>
#include "Port_IO.h"

TEXT* debug = {  pos_x=20;  pos_y=20;  size_y=400; font="Arial#20b";  strings=20;  flags=SHOW + WWRAP;  }

var hPort;

function main()
{
	wait(1);	level_load(NULL);	wait(1);	diag("\n\n\n");
	on_esc = NULL;
	//
	//

	hPort = port_open_readwrite("COM9", "2400,n,8,1");
	
	wait(-1);
	//	
	while(1)
	{
		str_cpy((debug.pstring)[0], "Port Handle = ");
		str_cat((debug.pstring)[0], _chr(str_for_int(NULL,hPort)));
		if(key_esc)	break;
		wait(1); 
		
	}
	port_close(hPort);
	//
	//
	sys_exit("");	
}



Maybe the port_close needs more time to finish its operation before A7 closing ?

Second, the port_open_xxxx command seems not to be able to open the port number larger the 9 (e.g. 10, 11, 12 ....). Is there a way to get around this problem? since I use a virtual com port through a usb converter, it is very easy to get a virtual com port number larger than 9.

I apologize for my bad english, your kindly response will be much appreciated.

Again, thank you for your wonderful contribution. I really think conitec should include your work in next update.