Download ActiveComport Serial Port Toolkit 3.1  (3008 KB - .exe file)
Download Manual  (118 KB - .htm file)
Using ActiveComport Serial Port Toolkit with VBScript
ActiveComport is a software development kit (SDK) that enables the user to communicate to a device over a serial interface.
Such a device can be: a weight indicator, a modem, a scanner, or any other device that is equiped with a serial port.
It can even be another PC, connected via a NULL modem cable.
ActiveComport features the following:
Direct COM port support (like 'COM1'), TAPI (Windows Telephony Device) support (like 'Standard 56000 bps Modem'),
support for RS-232/RS422/RS485, up to 256 simultaneous ports, support for all types of Hayes compatible modems,
support for serial cable, USB cable or Bluetooth connections, support for GSM/GPRS modems,
support for Virtual COM ports (i.e. COM ports redirected through the network), hardware flow control (RTS/CTS, DTR/DSR), software flowcontrol (XON/XOFF),
configurable baudrate/parity/stopbits, full buffered data transfer, text/binary data transfer.
ActiveComport can be well integrated into VBScript environments.
This document describes how ActiveComport can be integrated into VBScript projects.
Step 1: Download and install the ActiveComport Toolkit
Download ActiveComport from the ActiveXperts Download Site and start the installation.
The installation guides you through the installation process.
Step 2: Create a new script
Create a new script using your favorite editor.
You can simply use notepad. However, a VBScript editor is recommended, so you can browse through objects, objects properties and object functions.
You're now able to write a more advanced script to communicate using the ActiveComport Toolkit.
Step 3: Create the ActiveComport object in VBScript
Create a new VBScript file called DEMO.VBS. It is recommended to insert the following line on top of your code:
Option Explicit
This statement requires that all variable names be defined (with the Dim statement),
to avoid simple typos that can cause incredible headaches and long debugging sessions for something that should have never happened.
Now, declare the ActiveComport object:
Dim objComPort
Create the ActiveComport object like this:
Set objComPort = CreateObject( "ActiveXperts.ComPort" )
Now, add the following lines to the file to have your fist ActiveComport VBScript program:
WScript.Echo "Version: " & objComPort.Version
WScript.Echo "Expiration Date: " & objComPort.Expiration Date
Step 4: Send an AT command to a connected hayes compatible modem
You can now send and/or receive data to an/or from a serial interface.
The following VBScript code shows how to query a modem:
Option Explicit
Dim numDevices, strDevices, i, str, objComport
Set objComport = CreateObject( "ActiveXperts.Comport" )
Wscript.Echo "ActiveComport " & objComport.Version & " demo."
Wscript.Echo "Expiration date: " & objComport.ExpirationDate & vbCrLf
' Set Device property
numDevices = objComport.GetDeviceCount()
strDevices = "*** Enter one of the following device names *** " & vbCrLf & vbCrLf
For i = 0 To numDevices - 1
strDevices = strDevices & objComport.GetDevice( i )
strDevices = strDevices & vbCrLf
Next
strDevices = strDevices & "COM1" & vbCrLf & "COM2" & vbCrLf & "COM ..." & vbCrLf
Do
objComport.Device = InputBox( strDevices, "Input" )
Loop until objComport.Device <> ""
objComport.BaudRate = 9600
objComport.HardwareFlowControl = True
objComport.SoftwareFlowControl = False
' Set Logging - for troubleshooting purposes
objComport.LogFile = "C:\ActiveComport.log"
' Open the port
objComport.Open
If( objComport.LastError <> 0 ) Then
Wscript.Echo "Open failed, Error #" & objComport.LastError & " : " & objComport.GetErrorDescription( objComport.LastError )
WScript.Echo "Ready."
WScript.Quit
End If
' Write command, and wait for the response
WriteStr objComport, "atz"
ReadStr objComport
' Write command, and wait for the response
WriteStr objComport, "at&f"
ReadStr objComport
' Close the port
objComport.Close
Set objComport = Nothing
WScript.Echo "Ready."
' ********************************************************************
' Sub Routines
' ********************************************************************
Sub WriteStr( obj, str )
obj.WriteString str
WScript.Echo "-> " & str
End Sub
' ********************************************************************
Sub ReadStr( obj )
str = "notempty"
obj.Sleep 200
Do While str <> ""
str = obj.ReadString
If( str <> "" ) Then
WScript.Echo "<- " & str
End If
Loop
End Sub
' ********************************************************************
There are many working samples included with the product.
You can also find them on the ActiveXperts FTP site: ftp.activexperts-labs.com/samples/acomport.
The ActiveComport tool is COM port development component (SDK). This control can be used by any Windows development platform,
including Visual Basic .NET, Visual CSharp .NET,
ASP .NET (VB,CS),
ASP,
Visual Basic,
Visual Studio/Visual C++,
Borland Delphi and
C++ Builder,
PHP,
VBA (Visual Basic for Applications),
ColdFusion,
HTML,
VBScript and any other ActiveX/COM compliant platform. The ActiveComport Toolkit is an ActiveXperts Software B.V. Product.
|