Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Serial ports (com1, com2..) programming (IO) in acucobol

Status
Not open for further replies.

NEO1961

Programmer
Oct 10, 2000
1
AR
If anybody knows how to write-to and read-from a serial port
from acucobol, y really neads your help.
I want to write to Fiscal Printer and read its answer and
status. All this throu the serial ports.
Thanks. [sig][/sig]
 
USE OTHER LANGUAGE - COBOL IS WELL-KNOWN FOR ITS USEFULNES
IN THE MANAGEMENT OF PORTS COMx.
ANYWAY, I THINK, THERE'S A DRIVER FOR FISCAL PRINTER RUNNING UNDER MS-DOS.
YOU CAN CONTACT INFOCOM S.A. IN ARGENTINA.
NAVIGATE AND LOOK FOR VENDOR'S LIST.

DO NOT EXPECT TOO MUCH.
 
I agree with Carlin. Cobol is not well suited for COM port work. There is, however, a way around it, but this is theoretical. Lemme know if this helps. This will only let you write to the port, though...

Assuming you're working under Windows, add a text only printer to Windows, and configure it so that it prints to COMx. Configure all communication settings (i.e. port speed, parity, etc) under the printer properties. Call this printer COM-PRINTER (for example).

In cobol, define a file as:
SELECT MY-PRINTER ASSIGN TO PRINTER "COM-PRINTER"
ORGANIZATION IS SEQUENTIAL.

Define a regular FD section for it, and then just open output, write, and close. Other OPEN modes would most probably not work (although maybe EXTEND will; don't know).

Finally, here's what the help file (v5.1.4) has to say about PRINTER files:

SELECT [OPTIONAL] file-name
ASSIGN TO [PRINT | PRINTER | PRINTER-1] [file-spec]

PRINT, PRINTER, PRINTER-1 - A sequential file marked with one of these device phrases will be treated as a "print" file. Print files may not be opened for INPUT or I/O. When records are written to a print file, trailing spaces are first removed from the record. Print files have printer carriage control information added to them as specified by the WRITE statements that add records to the file. If "PRINTER" or "PRINTER-1" is specified, and no file-spec is specified, then the external file name is treated as "PRINTER" or "PRINTER-1" (unless RM/COBOL compatibility mode is being used, in which case rule 6 applies instead). Normally, these names are translated at runtime to the name of the system spooler. This is an exception to rule 6 above.

The next best thing to this is to use a COM port OCX control (which I'm sure you can get from tons of places on the net) and incoporate it into ACU. OCX object are rpetty well supported and are actually fun to work with.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top