Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: pComOpen pGetLastError(1)
display(3,"Please wait...","Looking for modem on COM4") port=pComOpen("COM4",0,9600,"8N1","XONXON") pPutString(port,"ATZ") pPutString(port,@cr) if pWaitFor(port,"OK","",0,3000)==0 pComClose(port,-1) goto NO_MODEM else ComPort=4 goto SHOWCOMPORT endif goto NO_MODEMThe error message is:
WIL Extender Error--------- port=pComOpen("COM4",0,9600,"8N1","XONXON") Winbatch 32.97D WIL Version 2.4dbpThere is no number in the Error Message, only a series of dashes. The PC on which this error message was generated does not have a COM4, but I've tested the same script on a PC that does, and get the same message. Is there a way to check either the validity of a COM port, or for an error message from pComOpen() ?
;=======================snip=========================== DirChange("c:\program files\WinBatch\system") AddExtender("wwser34I.dll") debug(1) display(3,"Please wait...","Looking for modem on COM4") ErrorMode(@off) port=pComOpen("COM4",0,9600,"8N1","XONXON") ErrorMode(@cancel) code=pGetLastError(1) Message("Open err msg",code) if port==- then exit pPutString(port,"ATZ") pPutString(port,@cr) if pWaitFor(port,"OK","",0,3000)==0 pComClose(port,-1) goto NO_MODEM else ComPort=4 goto SHOWCOMPORT endif goto NO_MODEM ;=======================================================After capturing the error code, do a StrIndex to test whether the code indicated an invalid port. Works great.
Article ID: W12570
Filename: Detecting Valid COM Ports.txt
File Created: 2001:03:01:15:25:26
Last Updated: 2001:03:01:15:25:26