 |
|
|
Topic: Invalid Port No Error
|
By: Lyall | Posted on: Sep 7 2015 at 02:37:07 AM | I am trialing Scomm32 with a view to incorporation it into a Visual FoxPro 9 project that I am coding. I am intermittently getting an error:
OLE IDespatch exception code 0 from Scomm32: Invalid Port Number.
The port number is obtained from an integer field in a data table, and held in a memory variable. It is then sent to Scomm32 by the following code:
SComm1.CommPort = lnEftcomportno && the port number
SComm1.settings = "9600,n,8,1"
pbPortOpen = .SComm1.PortOpen && pbPortOpen is a Boolean memory variable
IF pbPortOpen = .F.
SComm1.PortOpen = .T.
ENDIF
The error occurs on the :Scomm1.PortOpen = .T." line. As I said, this is only intermitant, not a constant error, but when it occurs, it causes major issues in my application.
I need to have a way of ensuring this error does not occur, or can be trapped and fixed, before fully committing to SComm32 and purchasing a license. I hope you can help with this.
| |
By: Guest | Posted on: Sep 10 2015 at 07:55:10 PM | How sure are you that your lnEftcomportno variable is always pointing to a valid port that is available.
Before trying to open the port. Try reading the .CommName property to see if youmget a valid string/name. If that property returns an empty string then the port does not exist or has a problem | |
By: Guest | Posted on: Sep 10 2015 at 07:56:27 PM | I'm not a VFP user. But does it have error trapping/catching? The error thrown by scomm should be trapable. | |
By: Guest | Posted on: Sep 11 2015 at 02:49:17 AM | Thanks for those replies, guys. I will certainly try the .CommName property, and do some error trapping for that if it is blank.
Yes, VFP does have a Try/Catch process, and if the .CommName one doesn't work, I'll try and use that. | |
|