Highlighted
Absent Member.
Absent Member.
645 views

[archive] Reading Serial Port...

[Migrated content. Thread originally posted on 02 November 2005]

Well...
Newbie, just found out Cobol has no provisions internal to collect serial port data.

I am writing AcuCobol GUI to replace FedEx Shipping software in house. I need to read FedEx scales on COM1.

I am told by AcuSupport Techie/Guru that options are:

1. Write my own C++ program.

2. Purchase 3rd Party ActiveX.

3. Access Windows API.


1. I am doing good to be able to read /program Cobol. I have Visual Studio Enterprise, but have no programming expertise.

2. We're broke, hence, writing our own Cobol software.

3. Access Windows API? Right!

I can already see that my only "doable" option is Windows API. I think this will be more direct, and have less "hurdles" to jump.

Any advice on how to proceed?
Where do I find Windows Serial API functions listed?
Is AcuCobol able to call kerrnel functions?
0 Likes
1 Reply
Highlighted
Absent Member.
Absent Member.

RE: [archive] Reading Serial Port...

ACUCOBOL-GT is absolutely able to call API functions, however, dealing with serial port communication is awful, I really don't think you want to go that path.
As you have Visual Studio Enterprise installed, you already have the Microsoft Common components installed I presume (if not they also ship on the ACUCOBOL-GT CD version 6.2 and later).
Among those controls are the MSCOMM32.OCX. This is a window less component for serial communication.
I suggest you check out the documentation on the MSComm component. Here is a vb code example I found on the msdn.

Private Sub Form_Load ()
   ' Buffer to hold input string
   Dim Instring As String
   ' Use COM1.
   MSComm1.CommPort = 1
   ' 9600 baud, no parity, 8 data, and 1 stop bit.
   MSComm1.Settings = "9600,N,8,1"
   ' Tell the control to read entire buffer when Input
   ' is used.
   MSComm1.InputLen = 0
   ' Open the port.
   MSComm1.PortOpen = True
   ' Send the attention command to the modem.
   MSComm1.Output = "ATV1Q0" & Chr$(13) ' Ensure that
   ' the modem responds with "OK".
   ' Wait for data to come back to the serial port.
   Do
      DoEvents
   Buffer$ = Buffer$ & MSComm1.Input
   Loop Until InStr(Buffer$, "OK" & vbCRLF)
   ' Read the "OK" response data in the serial port.
   ' Close the serial port.
   MSComm1.PortOpen = False
End Sub
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.