Version property
Description:
Version information of ActiveComport. This property is read-only; you cannot assign a value to it.
Example:
Set objComport = CreateObject("ActiveXperts.Comport") ' Create a new Comport instance
WScript.Echo "Version: " & objComport.Version
Build property
Description:
Build information of ActiveComport. This property is read-only; you cannot assign a value to it.
Example:
Set objComport = CreateObject("ActiveXperts.Comport") ' Create a new Comport instance
WScript.Echo "Version: " & objComport.Version
WScript.Echo "Build: " & objComport.Build
ExpirationDate property
Description:
Expiration date of ActiveComport. This property is read-only; you cannot assign a value to it.
Once you have registered the product, the property holds the empty string ("") value.
Example:
Set objComport = CreateObject("ActiveXperts.Comport") ' Create a new Comport instance
WScript.Echo "ExpirationDate: " & objComport.ExpirationDate
LastError property
Description:
The result of a previous called function.
Use it to check the result of your last function call.
A zero indicates: success. Any non-zero value means an error.
The GetErrorDescription function provides the error description of an error code.
For a complete list of error codes, check out the following page: www.activexperts.com/support/errorcodes.
Example:
Set objComport = CreateObject("ActiveXperts.Comport") ' Create a new Comport instance
...
objComport.Open ' Open the port
WScript.Echo "LastError: " & objSnmp.LastError ' Display the result
...
Device property
Description:
Device driver to use.
You can either use a Windows telephony device (recommended) or a physical COM port (directly).
Assign one of the following strings to the 'Device' property:
- A valid Windows telephony device name - this must be the literal name as it appears in Modems
tab of the Phone and Modems Options applet in the Control Panel. For
instance: "Standard 9600 bps Modem";
Use the GetDevice function to
retrieve Windows telephony device names;
-
A valid COM port string, formatted as COMx, where x is a valid
COM port number. When you assign the 'Device' property with a COM port string,
you bypass all Windows telephony intelligence, like dialing rules, port sharing and so on.
Windows telephony devices are highly recommended.
Example:
Set objComport = CreateObject("ActiveXperts.Comport") ' Create a new Comport instance
objComport.Device = "Standard 19200 bps Modem" ' Use a Windows telephony device (recommended)
...
BaudRate property
Description:
Baud rate at which the communications device operates.
The default value is 0, which means that the baud rate setting is inherited from the Port/Device settings in the Control Panel of Windows.
You should use the UpdateCom function if you want to change the baudrate and the port is already opened.
This property can be one of the following values:
- 0 (Default - inherit baud rate from the device settings as defined in the Control Panel)
- 110
- 300
- 600
- 1200
- 2400
- 4800
- 9600
- 14400
- 19200
- 38400
- 56000
- 57600
- 115200
- 128000
- 230400
- 256000
- 460800
- 921800
Example:
Set objComport = CreateObject("ActiveXperts.Comport") ' Create a new Comport instance
objComport.Device = "COM2" ' Set device to COM2
objComport.BaudRate = 38400 ' Use 38400 bps
objComport.Open
...
DataBits property
Description:
Number of databits in a byte.
The default value is asDATABITS_DEFAULT, which means that the data bits setting is inherited from the Port/Device settings in the Control Panel of Windows.
You cannot change the value when the port is already opened.
Example:
Set objComport = CreateObject("ActiveXperts.Comport") ' Create a new Comport instance
objComport.Device = "COM2" ' Set device to COM2
objComport.DataBits = objComport.asDATABITS_7 ' Use 7 bit data bits
objComport.Open
...
StopBits property
Description:
You can configure StopBits to be asSTOPBITS_DEFAULT, asSTOPBITS_1, asSTOPBITS_2 or asSTOPBITS_15.
If StopBits is asSTOPBITS_1, one stop bit is used to indicate the end of data transmission.
If StopBits is asSTOPBITS_2, two stop bits are used to indicate the end of data transmission.
If StopBits is asSTOPBITS_15, the stop bit is transferred for 150% of the normal time used to transfer one bit.
The default value is asSTOPBITS_DEFAULT, which means that the stop bits setting is inherited from the Port/Device settings in the Control Panel of Windows.
You cannot change the value when the port is already opened.
Example:
Set objComport = CreateObject("ActiveXperts.Comport") ' Create a new Comport instance
objComport.Device = "COM2" ' Set device to COM2
objComport.StopBits = objComport.asSTOPBITS_15 ' Use 1.5 stop bits
objComport.Open
...
Parity property
Description:
Parity checking can detect errors of one bit only. An error in two bits might cause the data to have a seemingly valid parity, when in fact it is incorrect.
You can configure Parity to be none, odd, even, mark, or space.
If Parity is asPARITY_DEFAULT, the parity setting is inherited from the Port/Device settings in the Control Panel of Windows.
If Parity is asPARITY_NONE (=none), parity checking is not performed and the parity bit is not transmitted.
If Parity is asPARITY_ODD (=odd), the number of mark bits (1's) in the data is counted, and the parity bit is asserted or unasserted to obtain an odd number of mark bits.
If Parity is asPARITY_EVEN (=even), the number of mark bits in the data is counted, and the parity bit is asserted or unasserted to obtain an even number of mark bits.
If Parity is asPARITY_MARK (=mark), the parity bit is asserted.
If Parity is asPARITY_SPACE (=space), the parity bit is unasserted.
The default value is asPARITY_DEFAULT.
You cannot change the value when the port is already opened.
Example:
Set objComport = CreateObject("ActiveXperts.Comport") ' Create a new Comport instance
objComport.Device = "COM2" ' Set device to COM2
objComport.Parity = objComport.asPARITY_NONE ' No parity
objComport.Open
...
HardwareFlowControl property
Descripton:
Example:
Set objComport = CreateObject("ActiveXperts.Comport") ' Create a new Comport instance
objComport.Device = "COM2" ' Set device to COM2
objComport.HardwareFlowControl = objComport.asFLOWCONTROL_DISABLE ' No hardware flow control
objComport.Open
...
DTRFlowControl property
Descripton:
Advanced Hardware Flow Control. Usually, the HardwareFlowControl property will suffice:
it sets all four advanced hardware flow control flags (DTRFlowControl, RTSFlowControl, CTSFlowControl, DSRFlowControl).
The default value is asFLOWCONTROL_DEFAULT, which means that the DTR flow control settings are inherited from the Port/Device settings in the Control Panel of Windows.
You cannot change the value when the port is already opened.
Example:
Set objComport = CreateObject("ActiveXperts.Comport") ' Create a new Comport instance
objComport.Device = "COM2" ' Set device to COM2
objComport.DTRFlowControl = objComport.asFLOWCONTROL_DISABLE ' No DTR hardware flow control
objComport.Open
...
RTSFlowControl property
Description:
Advanced Hardware Flow Control. Usually, the HardwareFlowControl property will suffice:
it sets all four advanced hardware flow control flags (DTRFlowControl, RTSFlowControl, CTSFlowControl, DSRFlowControl).
The default value is asFLOWCONTROL_DEFAULT, which means that the RTS flow control settings are inherited from the Port/Device settings in the Control Panel of Windows.
You cannot change the value when the port is already opened.
Example:
Set objComport = CreateObject("ActiveXperts.Comport") ' Create a new Comport instance
objComport.Device = "COM2" ' Set device to COM2
objComport.RTSFlowControl = objComport.asFLOWCONTROL_DISABLE ' No RTS
objComport.Open
...
CTSFlowControl property
Description:
Advanced Hardware Flow Control. Usually, the HardwareFlowControl property will suffice:
it sets all four advanced hardware flow control flags (DTRFlowControl, RTSFlowControl, CTSFlowControl, DSRFlowControl).
The default value is asFLOWCONTROL_DEFAULT, which means that the CTS flow control settings are inherited from the Port/Device settings in the Control Panel of Windows.
You cannot change the value when the port is already opened.
Example:
Set objComport = CreateObject("ActiveXperts.Comport") ' Create a new Comport instance
objComport.Device = "COM2" ' Set device to COM2
objComport.CTSFlowControl = objComport.asFLOWCONTROL_DISABLE ' No CTS hardware flow control
objComport.Open
...
DSRFlowControl property
Description:
Advanced Hardware Flow Control. Usually, the HardwareFlowControl property will suffice:
it sets all four advanced hardware flow control flags (DTRFlowControl, RTSFlowControl, CTSFlowControl, DSRFlowControl).
The default value is asFLOWCONTROL_DEFAULT, which means that the DSR flow control settings are inherited from the Port/Device settings in the Control Panel of Windows.
You cannot change the value when the port is already opened.
Example:
Set objComport = CreateObject("ActiveXperts.Comport") ' Create a new Comport instance
objComport.Device = "COM2" ' Set device to COM2
objComport.DSRFlowControl = objComport.asFLOWCONTROL_DISABLE ' No DSR hardware flow control
objComport.Open
...
SoftwareFlowControl property
Description:
Software flow control. You should use the UpdateCom function if you want to change the baudrate after you have opened the port.
The default value is asFLOWCONTROL_DEFAULT, which means that the software flow control settings are inherited from the Port/Device settings in the Control Panel of Windows.
The other valid values are: asFLOWCONTROL_DISABLE and asFLOWCONTROL_ENABLE.
Example:
Set objComport = CreateObject("ActiveXperts.Comport") ' Create a new Comport instance
objComport.Device = "COM2" ' Set device to COM2
objComport.SoftwareFlowControl = objComport.asFLOWCONTROL_ENABLE ' Use software flow control
objComport.Open
...
ComTimeout property
Description:
Timeout of ReadString function, in milliseconds. You can call this function anytime you want.
The default value is 1000.
Example:
Set objComport = CreateObject("ActiveXperts.Comport") ' Create a new Comport instance
objComport.Device = "Standard 9600 bps Modem" ' Set device to Standard 9600 bps Modem
str = objComport.ReadString ' Blocks until string is read or 1 sec is elapsed
WScript.Echo str
objComport.ComTimeout = 5000 ' Set timeout to 5000 msecs
str = objComport.ReadString ' Blocks until string is read or 5 sec is elapsed
WScript.Echo str
objComport.Close ' Close port
...
IsOpened property
Description:
True if port is opened, otherwise False.
Example:
Set objComport = CreateObject("ActiveXperts.Comport") ' Create a new Comport instance
objComport.Device = "Standard 9600 bps Modem" ' Set device to Standard 9600 bps Modem
If( objComport.IsOpened ) Then
WScript.Echo "Port is opened"
objComport.Close ' Close port
End If
PreCommandDelay property
Description:
Specifies a delay (in milliseconds) used before WriteString actually starts writing the command string.
This property was introduced to support slow devices that do not accept a few commands right after eachother.
These devices need a small delay between commands, which can be accomplished by setting this 'PreCommandDelay' property.
Note that the property does NOT apply to the WriteBytes and WriteByte functions.
Default value: 0, indicating no delay between commands.
Example:
Set objComport = CreateObject("ActiveXperts.Comport") ' Create a new Comport instance
objComport.Device = "Standard 9600 bps Modem" ' Set device to Standard 9600 bps Modem
objComport.Open ' Now open the port
If( objComport.LastError = 0 ) Then
objComport.PreCommandDelay = 500 ' WriteString will use a delay of 500 msecs
' before the command string is sent
objComport.InterCharDelay = 10 ' A delay of 10 milliseconds between each character
' Transmitted by the WriteString function
...
objComport.WriteString "AT&F"
...
objComport.Close ' Close the port
End If
InterCharDelay property
Description:
Specifies a delay (in milliseconds) used in WriteString between each character transmitted.
This property was introduced to support slow devices that do not allow each character tranmitted right after eachother in command mode.
These devices need a small delay between characters, which can be accomplished by setting this 'InterCharDelay' property.
Note that the property does NOT apply to the WriteBytes function.
Default value: 0, indicating no delay between characters.
Example:
Set objComport = CreateObject("ActiveXperts.Comport") ' Create a new Comport instance
objComport.Device = "Standard 9600 bps Modem" ' Set device to Standard 9600 bps Modem
objComport.Open ' Now open the port
If( objComport.LastError = 0 ) Then
objComport.PreCommandDelay = 500 ' WriteString will use a delay of 500 msecs
' before the command string is sent
...
objComport.InterCharDelay = 10 ' Delay of 10 milliseconds between each character
' transmitted by the WriteString function
objComport.WriteString "AT&F"
...
objComport.Close ' Close the port
End If
NewLine property
Description:
The character sequence that forms a newline.
Default value: the CR (carriage return) string.
Most frequent used newline strings:
- CR (carriage return) - a string containing only the ASCII-13 character (in C: "\r"; in VB: vbCr )
- LF (linefeed) - a string containing only the ASCII-10 character (in C: "\n"; in VB: vbLf )
- CRLF (carriage return / linefeed) - a string containing the ASCII-13, ASCII-10 sequence (in C: "\r\n"; in VB: vbCrLf )
A newline is used internally by two functions:
- ReadString - bytes are read from the port until a newline is detected;
- WriteString - bytes are written to the port. Finally a newline is sent.
Example:
Set objComport = CreateObject("ActiveXperts.Comport") ' Create a new Comport instance
objComport.Device = "Standard 9600 bps Modem" ' Set device to Standard 9600 bps Modem
objComport.Open ' Now open the port
If( objComport.LastError = 0 ) Then
objComport.NewLine = vbCrLf ' Use CRLF in the subsequent ReadBytes/WriteBytes calls ' transmitted by the WriteString function
objComport.WriteString "AT&F" ' AT&F is sent, followed by a CRLF
...
objComport.Close ' Close the port
End If
LogFile property
Description:
By default, LogFile holds the empty string and nothing is logged. If you assign a valid file name to it, all device commands and responses will be written to this log file.
Output is always appended.
Example:
Set objComport = CreateObject("ActiveXperts.Comport") ' Create a new Comport instance
objComport.LogFile = "C:\MyLogFile.txt" ' All operations are logged here
objComport.Device = "Standard 9600 bps Modem" ' Set device to Standard 9600 bps Modem
objComport.Open ' Open the port
...
Clear function
Description:
Reset all properties to their initial values.
Parameters:
None.
Return value:
Always 0.
Example:
Set objComport = CreateObject("ActiveXperts.Comport") ' Create a new Comport instance
objComport.Device = "Standard 9600 bps Modem" ' Set device to Standard 9600 bps Modem
objComport.Open
...
objComport.Close
objComport.Clear ' Clear all properties
objComport.Device = "COM1" ' Set device to COM1:
objComport.Open
...
GetDeviceCount function
Description:
Returns the number of installed Windows telephony devices on the local computer.
Parameters:
Return value:
The number of installed Windows telephony devices. Check the LastError
property to see if the function was completed successfully.
NOTE: The number of Windows telephony devices does not include the number installed COM ports.
Example:
Set objComport = CreateObject("ActiveXperts.Comport") ' Create a new Comport instance
WScript.Echo "Number of installed Windows telephony devices: " & objComport.GetDeviceCount()
GetDevice function
Description:
Returns the n-th telephony device of the system. The number n can be between
0 and GetDeviceCount()-1.
Parameters:
- Zero based index, to iterate over all telephony devices.
Return value:
The name of the device. Call the LastError
function to see if the function was completed successfully.
The name of the device can be assigned to the Device
property to open a Windows telephony device.
Example:
Set objComport = CreateObject("ActiveXperts.Comport") ' Create a new Comport instance
n = objComport.GetDeviceCount()
For i = 0 to n-1
WScript.Echo "Device " & i & ": " & objComport.GetDevice( i )
Next
Example:
Set objComport = CreateObject("ActiveXperts.Comport") ' Create a new Comport instance
If( objComport.GetDeviceCount() > 0 )
objComport.Device = objComport.GetDevice( 0 ) ' Use the first telephony device
objComport.WriteByte 32
End If
Open function
Description:
Open the comport. The Device indicates to port to open.
Parameters:
None.
Return value:
Always 0. Check LastError property to see if the function was completed successfully.
Example:
Set objComport = CreateObject("ActiveXperts.Comport") ' Create a new Comport instance
objComport.Device = "Standard 9600 bps Modem" ' Set device to Standard 9600 bps Modem
objComport.Open ' Now open the port
...
Close function
Description:
Close the COM port.
Parameters:
None.
Return value:
Always 0. Check LastError property to see if the function was completed successfully.
Example:
Set objComport = CreateObject("ActiveXperts.Comport") ' Create a new Comport instance
objComport.Device = "Standard 9600 bps Modem" ' Set device to Standard 9600 bps Modem
objComport.Open ' Now open the port
If( objComport.LastError = 0 ) Then
...
objComport.Close ' Close the port
End If
ClearTX function
Description:
Clears the output buffer (if the device or UART has one).
Parameters:
None.
Return value:
Always 0. Check LastError property to see if the function was completed successfully.
Example:
Set objComport = CreateObject("ActiveXperts.Comport") ' Create a new Comport instance
objComport.Device = "Standard 9600 bps Modem" ' Set device to COM2
objComport.Open ' Now open the Standard 9600 bps Modem
If( objComport.LastError = 0 ) Then
...
objComport.ClearTX ' Clear transmission queue
objComport.WriteString "AT&F"
...
objComport.Close ' Close the port
End If
ClearRX function
Description:
Clears the input buffer (if the device or UART has one).
Parameters:
None.
Return value:
Always 0. Check LastError property to see if the function was completed successfully.
Example:
Set objComport = CreateObject("ActiveXperts.Comport") ' Create a new Comport instance
objComport.Device = "Standard 9600 bps Modem" ' Set device to Standard 9600 bps Modem
objComport.Open ' Now open the port
If( objComport.LastError = 0 ) Then
...
objComport.ClearTX ' Clear transmission queue
objComport.ClearRX ' Clear transmission queue
...
objComport.WriteString "AT&F"
WScript.Echo objComport.ReadString ' Read incoming data
...
objComport.Close ' Close the port
End If
WriteString function
Description:
This function sends a string of ASCII data to the device. Finally NewLine is sent to the device.
Parameters:
Return value:
Always 0. Check LastError property to see if the function was completed successfully.
Example:
Set objComport = CreateObject("ActiveXperts.Comport") ' Create a new Comport instance
objComport.Device = "Standard 9600 bps Modem" ' Set device to Standard 9600 bps Modem
objComport.Open ' Now open the port
If( objComport.LastError = 0 ) Then
...
objComport.WriteString "AT&F"
...
objComport.Close ' Close the port
End If
WriteByte function
Description:
This function sends a (binary) byte to the device.
Parameters:
Return value:
Always 0. Check LastError property to see if the function was completed successfully.
Example:
Set objComport = CreateObject("ActiveXperts.Comport") ' Create a new Comport instance
objComport.Device = "Standard 9600 bps Modem" ' Set device to Standard 9600 bps Modem
objComport.Open ' Now open the port
If( objComport.LastError = 0 ) Then
...
objComport.WriteByte 97 ' [A]
objComport.WriteByte 116 ' [T]
objComport.WriteByte 122 ' [Z]
objComport.WriteByte 13 ' [<CR>]; ATZ issued.
...
objComport.Close ' Close the port
End If
WriteBytes function
Description:
Send a stream of binary data to the device.
Parameters:
Return value:
Always 0. Check LastError property to see if the function was completed successfully.
Example:
Set objComport = CreateObject("ActiveXperts.Comport") ' Create a new Comport instance
objComport.Device = "Standard 9600 bps Modem" ' Set device to Standard 9600 bps Modem
objComport.Open ' Now open the port
If( objComport.LastError = 0 ) Then
...
data = Chr( 1 ) & Chr( 2 ) & Chr( 253 ) & Chr( 254 ) & Chr( 255 )
objComport.WriteBytes data ' Write stream of data
...
objComport.Close ' Close the port
End If
ReadString function
Description:
This function reads a string of data from the device.
The function returns when either a string, terminated by a NewLine, is read from the device,
or when the time specified by ComTimeout has elapsed.
In case of a timeout, the empty string will be returned and LastError will indicate a time-out.
Parameters:
None.
Return value:
The string that was read from the device.
Check LastError property to see if the function was completed successfully.
In case of a timeout, the empty string is returned, and LastError will indicate a time-out.
Example:
Set objComport = CreateObject("ActiveXperts.Comport") ' Create a new Comport instance
objComport.Device = "Standard 9600 bps Modem" ' Set device to Standard 9600 bps Modem
objComport.Open ' Now open the port
If objComport.LastError = 0 Then
objComport.ComTimeout = 2000
str = objComport.ReadString ' Function will timeout after 2000 msec
WScript.Echo "String read: " & str
...
objComport.Close
End If
ReadByte function
Description:
This function reads one byte of data from the device.
The function returns when either a byte is read from the device,
or when the time specified by ComTimeout has elapsed.
In case of a timeout, LastError will indicate a time-out.
Parameters:
None.
Return value:
The byte that was read from the device.
Check LastError property to see if the function was completed successfully.
In case of a timeout, the LastError will be set to indicate a timeout.
Example:
Set objComport = CreateObject("ActiveXperts.Comport") ' Create a new Comport instance
objComport.Device = "Standard 9600 bps Modem" ' Set device to COM2
objComport.Open ' Now open the port
If objComport.LastError = 0 Then
objComport.ComTimeout = 2000
..
bt = objComport.ReadByte
If( objComport.LastError = 0 ) Then ' Function will timeout after 2000 msec
WScript.Echo "Byte read: " & bt
End If
...
objComport.Close
End If
ReadBytes function
Description:
This function reads a stream of binary data from the device.
The function returns when when the time specified by ComTimeout has elapsed.
Parameters:
None.
Return value:
The function returns when when the time specified by ComTimeout has elapsed.
If data was read from the port, 0 will be returned;
in case of a timeout without data being read from the port, the LastError property will indicate a timeout.
Example:
Set objComport = CreateObject("ActiveXperts.Comport") ' Create a new Comport instance
objComport.Device = "Standard 9600 bps Modem" ' Set device to Standard 9600 bps Modem
objComport.Open ' Now open the port
If objComport.LastError = 0 Then
objComport.ComTimeout = 2000
...
btData = objComport.ReadBytes ' Read stream of binary data
If( objComport.LastError = 0 ) Then ' Function will timeout after 2000 msec
WScript.Echo "Number of bytes read: " & Len( btData )
End If
...
objComport.Close
End If
UpdateCom function
Description:
If a COM port is already opened and you changed the baudrate or Software Flow Control,
you must this function to let the changes take effect.
of the comport.
Parameters:
None.
Return value:
The function returns when when the time specified by ComTimeout has elapsed.
If data was read from the port, 0 will be returned;
in case of a timeout without data being read from the port, the LastError property will indicate a timeout.
Example:
Set objComport = CreateObject("ActiveXperts.Comport") ' Create a new Comport instance
objComport.Device = "Standard 9600 bps Modem" ' Set device to Standard 9600 bps Modem
objComport.Open ' Now open the port
If objComport.LastError = 0 Then
objComport.BaudRate = 57600 ' Use different baudrate
objComport.SoftwareFlowControl = asFLOWCONTROL_ENABLE ' Use software flow control
objComport.UpdateCom ' Update COM port
...
objComport.Close
End If
RaiseRTS function
Description:
Raise (or lower) the RTS (Request-To-Send) signal. Raising this signal has nothing to do with the HardwareFlowControl property:
'RaiseRTS' just raises (or lowers) the RTS signal, regardless of the hardware flow control used.
Parameters:
Boolean: True to raise the signal, or False to lower the signal.
Return value:
Always 0. Check LastError property to see if the function was completed successfully.
Example:
Set objComport = CreateObject("ActiveXperts.Comport") ' Create a new Comport instance
objComport.Device = "Standard 9600 bps Modem" ' Set device to Standard 9600 bps Modem
objComport.Open ' Now open the port
If objComport.LastError = 0 Then
objComport.RaiseRTS( True ) ' Raise RTS
...
objComport.RaiseRTS( False ) ' Lower RTS
...
objComport.Close
End If
RaiseDTR function
Description:
Raise (or lower) the DTR (Data-Terminal-Ready) signal.
Raising this signal has nothing to do with the HardwareFlowControl property:
'RaiseDTR' just raises (or lowers) the DTR signal, regardless of the hardware flow control used.
Parameters:
- Boolean: True to raise the signal, or False to lower the signal.
Return value:
Always 0. Check LastError property to see if the function was completed successfully.
Example:
Set objComport = CreateObject("ActiveXperts.Comport") ' Create a new Comport instance
objComport.Device = "Standard 9600 bps Modem" ' Set device to Standard 9600 bps Modem
objComport.Open ' Now open the port
If objComport.LastError = 0 Then
objComport.RaiseDTR( True ) ' Raise DTR
...
objComport.RaiseDTR( False ) ' Lower DTR
...
objComport.Close
End If
QueryCTS function
Description:
Query the actual value of the CTS (Clear-To-Send) signal.
Parameters:
None.
Return value:
True if CTS is raised, otherwise: False
Example:
Set objComport = CreateObject("ActiveXperts.Comport") ' Create a new Comport instance
objComport.Device = "Standard 9600 bps Modem" ' Set device to Standard 9600 bps Modem
objComport.Open ' Now open the port
If objComport.LastError = 0 Then
...
bVal = objComport.QueryCTS() ' Query CTS signal
WScript.Echo "CTS: " & bVal
...
objComport.Close
End If
QueryDSR function
Description:
Query the actual value of the DSR (Data-Set-Ready) signal.
Parameters:
None.
Return value:
True if DSR is raised, otherwise: False
Example:
Set objComport = CreateObject("ActiveXperts.Comport") ' Create a new Comport instance
objComport.Device = "Standard 9600 bps Modem" ' Set device to Standard 9600 bps Modem
objComport.Open ' Now open the port
If objComport.LastError = 0 Then
...
bVal = objComport.QueryDSR() ' Query DSR signal
WScript.Echo "DSR: " & bVal
...
objComport.Close
End If
QueryDCD function
Description:
Query the actual value of the DCD (Data-Carrier-Detect) signal.
Parameters:
None.
Return value:
True if DCD is raised, otherwise: False
Example:
Set objComport = CreateObject("ActiveXperts.Comport") ' Create a new Comport instance
objComport.Device = "Standard 9600 bps Modem" ' Set device to Standard 9600 bps Modem
objComport.Open ' Now open the port
If objComport.LastError = 0 Then
...
bVal = objComport.QueryDCD() ' Query DCD signal
WScript.Echo "DCD: " & bVal
...
objComport.Close
End If
QueryRI function
Description:
Query the actual value of the RI (Ring-Indicator) signal.
Parameters:
None.
Return value:
True if RI is raised, otherwise: False
Example:
Set objComport = CreateObject("ActiveXperts.Comport") ' Create a new Comport instance
objComport.Device = "Standard 9600 bps Modem" ' Set device to Standard 9600 bps Modem
objComport.Open ' Now open the port
If objComport.LastError = 0 Then
...
bVal = objComport.QueryRI() ' Query RI signal
WScript.Echo "RI: " & bVal
...
objComport.Close
End If
Sleep function
Description:
This function can be used in your script anywhere you want; it will suspend the program.
One paramter is required: the number of milliseconds you want to suspend.
Parameters:
- Number of milliseonds to suspend
Return value:
Always 0. Check LastError property to see if the function was completed successfully.
Example:
Set objComport = CreateObject("ActiveXperts.Comport") ' Create a new Comport instance
objComport.Device = "Standard 9600 bps Modem" ' Set device to Standard 9600 bps Modem
objComport.Open ' Now open the port
If objComport.LastError = 0 Then
objComport.WriteString( "AT&F" ) ' Suspend for 1000 msecs, then resume
objComport.Sleep( 1000 )
WScript.Echo objComport.ReadString
objComport.Close
End If
GetErrorDescription function
Description:
GetErrorDescription provides the error description of a given error code.
Parameters:
Return value:
The error description that is associated with the given error code.
Example:
Set objComport = CreateObject("ActiveXperts.Comport") ' Create a new Comport instance
objComport.Device = "COM9" ' Set device to COM9
...
WScript.Echo "LastError: " & objComport.LastError
WScript.Echo "Error description: " & objComport.GetErrorDescription( objComport.LastError )
...
Activate function
Description:
This function activates the ActiveComport product. A valid registrationcode must be passed as parameter.
Parameters:
Return value:
Always 0. Check LastError property to see if the function was completed successfully.
Example:
Set objComport = CreateObject("ActiveXperts.Comport") ' Create a new Comport instance
objComport.Activate "xxxxx-xxxxx-xxxxx" ' Use a valid registration code