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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Redirecting console input/output

Status
Not open for further replies.

rchilausky

Programmer
Dec 11, 2003
1
US
I am using Fujitsu Cobol V3 (the free version) to learn Cobol. One of the capabilities that I need to exercise is reading and writing to a Windows application window. I am able to read and write to the console window via DISPLAYs and ACCEPTs. How do I redirect the I/O from the console window to an application window, specifically a telnet session window?
 
Here is a progran that uses standard input/output like a filter.

Hope this helps on redirect.

00010****************************************************************************
000011* START OF THE IDENTIFICATION DIVISION *
000012****************************************************************************
000013 IDENTIFICATION DIVISION.
000020 PROGRAM-ID. INV-RPT.
000030****************************************************************************
000031* START OF THE ENVIRONMENT DIVISION *
000032****************************************************************************
000040 ENVIRONMENT DIVISION.
000050 CONFIGURATION SECTION.
000051 SPECIAL-NAMES.
000052 PRINTING MODE CHAR-TYPE IS
000053 FOR ALL
000055 IN SIZE 6 POINT
000057 AT PITCH 13
000058 WITH FONT GOTHIC
000059 AT ANGLE 0 DEGREES
000060 BY FORM F0202.
000061 INPUT-OUTPUT SECTION.
000062 FILE-CONTROL.
000070 SELECT INVENTORY-FILE-IN
000081* ASSIGN TO SYSIN
000090 ASSIGN TO "KYBD:"
000091 ORGANIZATION IS LINE SEQUENTIAL.
000100 SELECT INVENTORY-LISTING-OUT
000110* ASSIGN TO SYSOUT
000120 ASSIGN TO "SCRN:"
000121 ORGANIZATION IS SEQUENTIAL.
000130****************************************************************************
000131* START OF THE DATA DIVISION *
000132****************************************************************************
000140 DATA DIVISION.
000150 FILE SECTION.
000160 FD INVENTORY-FILE-IN.
000170 01 INVENTORY-RECORD-IN.
000180 02 INV-RECORD-IN.
000190 03 ITEM PIC X(6).
000200 03 DESCRIPTION PIC X(20).
000210 03 UNITCOST PIC 99V99.
000211 03 UNITSELL PIC 99V99.
000212 03 ONHAND PIC 9(4).
000220 03 ONORDER PIC 9(4).
000230 03 ORDERPOINT PIC 9(4).
000280 03 FILLER PIC X(34).
000281 FD INVENTORY-LISTING-OUT.
000290 01 INVENTORY-RECORD-OUT CHARACTER TYPE CHAR-TYPE.
000300 02 INV-LINE-OUT.
000310 03 ITEM PIC X(6).
000320 03 FILLER PIC X.
000330 03 DESCRIPTION PIC X(19).
000340 03 FILLER PIC X.
000350 03 ONHAND PIC Z(4).
000360 03 FILLER PIC X(2).
000370 03 ONORDER PIC Z(4).
000380 03 FILLER PIC XX.
000390 03 ORDERPOINT PIC Z(4).
000400 03 FILLER PIC Z.
000410 03 UNITCOST PIC Z9.99.
000420 03 FILLER PIC X.
000430 03 UNITSELL PIC Z9.99.
000440 03 FILLER PIC X.
000450 03 TOTALCOST PIC $$,$$$,$$9.99.
000460 03 FILLER PIC XXX.
000470 03 TOTALSELL PIC $$,$$$,$$9.99.
000480 03 FILLER PIC XX.
000490 03 ORDERAMOUNT PIC Z(4).
000500 03 FILLER PIC XXX.
000510 03 PROFIT-RATIO-OUT PIC Z.ZZ.
000520 03 FILLER PIC X.
000530 03 ASTERISTIC PIC X.
000584 01 LINE-RECORD CHARACTER TYPE CHAR-TYPE.
000585 03 FILLER PIC X(132).
000593****************************************************************************
000594* BEGINNING OF THE WORKING STORAGE SECTION *
000595****************************************************************************
000596 WORKING-STORAGE SECTION.
000597 01 HEADING-RECORD-1.
000598 03 PIC X(42) VALUE SPACES.
000599 03 PIC X(16) VALUE "SPARKS CORP.".
000600 03 PIC X(22) VALUE SPACES.
000601 01 HEADING-RECORD-2.
000602 03 PIC X(40) VALUE SPACES.
000603 03 PIC X(16) VALUE "INVENTORY REPORT".
000604 03 PIC X(31) VALUE SPACES.
000605 03 PIC X(6) VALUE "PAGE ".
000606 03 COUNTER PIC 99.
000607 01 HEADING-RECORD-3.
000608 03 PIC X(20) VALUE " PART PART ".
000613 01 HEADING-RECORD-4.
000614 03 PIC X(20) VALUE " NO DESCRIPTION ".
000619 01 PRINT-PAGE-TOTALS.
000620 03 FILLER PIC X(42) VALUE SPACES.
000621 03 PIC X(12) VALUE "PAGE TOTALS ".
000622 03 PRINT-PAGE-TOTAL-C PIC $$,$$$,$$9.99.
000625 01 PRINT-FINAL-TOTALS.
000626 03 FILLER PIC X(42) VALUE SPACES.
000627 03 PIC X(12) VALUE "FINAL TOTALS".
000628 03 PRINT-FINAL-TOTAL-C PIC $$,$$$,$$9.99.
000665 01 DATE-AREA.
000666 03 YEAR PIC 9999.
000667 03 MONTH PIC 99.
000668 03 WEEK-DAY PIC 99.
000669 03 HOUR PIC 99.
000670 03 MINUTES PIC 99.
000671 03 SECONDS PIC 99.
000672 03 PARTIALSECONDS PIC 99.
000673 03 DATE-SIGN PIC X.
000674 03 EXTRA PIC 9999.
000675 01 DATE-AREA-EDITED.
000676 03 FILLER PIC X(33) VALUE SPACES.
000677 03 MONTH PIC 99.
000678 03 FILLER PIC X VALUE "/".
000679 03 WEEK-DAY PIC 99.
000680 03 FILLER PIC X VALUE "/".
000681 03 YEAR PIC 9999.
000682 03 FILLER PIC XXX VALUE " ".
000683 03 HOUR PIC 99.
000684 03 FILLER PIC X VALUE ":".
000685 03 MINUTES PIC 99.
000686 03 FILLER PIC X VALUE ":".
000687 03 SECONDS PIC 99.
000688 03 FILLER PIC X VALUE ":".
000689 03 PARTIALSECONDS PIC 99.
000690 03 FILLER PIC XXX VALUE " ".
000691 03 DATE-SIGN PIC X.
000692 03 EXTRA PIC 9999.
000693 01 PAGE-TOTALCOST PIC S999999V99 COMPUTATIONAL.
000695 01 FINAL-TOTALCOST PIC S9999999V99 COMPUTATIONAL.
000697 01 PERCENT PIC 99V9 COMPUTATIONAL.
000698 01 PROFIT-RATIO PIC 999V99 COMPUTATIONAL.
000699 01 WORK-AREA PIC S9999V999 COMPUTATIONAL.
000700 01 AMOUNT-TO-ORDER PIC S9999 COMPUTATIONAL.
000701 01 ONEHALF PIC 99 VALUE 50.
000702 01 PAGECOUNT PIC 99 VALUE 1 COMPUTATIONAL.
000703 01 LINE-COUNT PIC 99 VALUE 0 COMPUTATIONAL.
000704 01 EOF-SWITCH PIC X VALUE "N".
000708****************************************************************************
000709* START OF THE PROCEDURE DIVISION *
000710****************************************************************************
000711 PROCEDURE DIVISION.
000712****************************************************************************
000713* START OF HOUSEKEEPING PROCEDURE *
000714****************************************************************************
000715 HOUSEKEEPING.
000717 OPEN INPUT INVENTORY-FILE-IN.
000718 OPEN OUTPUT INVENTORY-LISTING-OUT.
000719 MOVE FUNCTION CURRENT-DATE TO DATE-AREA.
000720 MOVE CORR DATE-AREA TO DATE-AREA-EDITED.
000726 PERFORM HEADING-ROUTINE.
000727****************************************************************************
000728* START OF ROUTINE TO READ THE RECORDS AND PROCESS THEM, PROCEDURE *
000729****************************************************************************
000730 GET-MORE.
000731 READ INVENTORY-FILE-IN AT END GO TO TERMINATE-PROGRAM.
000732 MOVE SPACES TO INV-LINE-OUT.
000733 MOVE CORR INV-RECORD-IN TO INV-LINE-OUT.
000734***************** CALCULATE TOTALS ********************************************
000735* MULTIPLY ONHAND IN INVENTORY-RECORD-IN BY UNITCOST IN INVENTORY-RECORD-IN
000736* GIVING WORK-AREA.
000737* MOVE WORK-AREA TO TOTALCOST IN INVENTORY-RECORD-OUT.
000738* ADD WORK-AREA TO PAGE-TOTALCOST.
000739* ADD WORK-AREA TO FINAL-TOTALCOST.
000740* MULTIPLY ONHAND IN INVENTORY-RECORD-IN BY UNITSELL IN INVENTORY-RECORD-IN
000741* GIVING WORK-AREA.
000742* MOVE WORK-AREA TO TOTALSELL.
000743* ADD WORK-AREA TO PAGE-TOTALSELL.
000744* ADD WORK-AREA TO FINAL-TOTALSELL.
000745***************** CALCULATE ORDER AMOUNT & PERCENT ****************************
000746* ADD ONHAND IN INVENTORY-RECORD-IN TO ONORDER IN INVENTORY-RECORD-IN
000747* GIVING WORK-AREA.
000748* MOVE ORDERPOINT IN INVENTORY-RECORD-IN TO AMOUNT-TO-ORDER.
000749* SUBTRACT WORK-AREA FROM AMOUNT-TO-ORDER.
000750* MULTIPLY WORK-AREA BY 100 GIVING WORK-AREA.
000751* DIVIDE WORK-AREA BY ORDERPOINT IN INVENTORY-RECORD-IN GIVING PERCENT ROUNDED.
000752* IF (PERCENT <= 50) THEN
000753* SUBTRACT AMOUNT-TO-ORDER FROM ORDERPOINT IN INVENTORY-RECORD-IN
000754* GIVING AMOUNT-TO-ORDER
000755* MOVE AMOUNT-TO-ORDER TO ORDERAMOUNT IN INVENTORY-RECORD-OUT
000756* ELSE
000757* MOVE ZEROS TO ORDERAMOUNT IN INVENTORY-RECORD-OUT
000758* END-IF.
000759******************* CALCULATE THE PROFIT RATIO ********************************
000760* DIVIDE UNITSELL IN INVENTORY-RECORD-IN BY
000761* UNITCOST IN INVENTORY-RECORD-IN GIVING PROFIT-RATIO ROUNDED.
000762* IF ( PROFIT-RATIO >= +1.32 ) THEN MOVE ZEROS TO PROFIT-RATIO.
000763* MOVE PROFIT-RATIO TO PROFIT-RATIO-OUT.
000764* MOVE &quot;*&quot; TO ASTERISTIC
000765*******************************************************************************
000766 WRITE INVENTORY-RECORD-OUT.
000769*******************************************************************************
000770 ADD 1 TO LINE-COUNT.
000771 IF (LINE-COUNT > 20) THEN PERFORM NEXT-PAGE.
000773* GO TO TERMINATE-PROGRAM.
000774 GO TO GET-MORE.
000776****************************************************************************
000777* START OF PRINT THE HEADING LINES & BLANK LINE PROCEDURES *
000778****************************************************************************
000779 HEADING-ROUTINE.
000780 MOVE HEADING-RECORD-1 TO LINE-RECORD.
000781 WRITE LINE-RECORD.
000782 MOVE PAGECOUNT TO COUNTER.
000783 ADD 1 TO PAGECOUNT.
000784 MOVE HEADING-RECORD-2 TO LINE-RECORD.
000785 WRITE LINE-RECORD.
000786 MOVE DATE-AREA-EDITED TO LINE-RECORD.
000787 WRITE LINE-RECORD.
000788 MOVE HEADING-RECORD-3 TO LINE-RECORD.
000789 WRITE LINE-RECORD AFTER ADVANCING 2.
000790 PERFORM WRITE-BLANK-LINE.
000791 MOVE HEADING-RECORD-4 TO LINE-RECORD.
000792 WRITE LINE-RECORD BEFORE ADVANCING 1.
000793****************************************************************************
000794* START OF PROCEDURE TO JUST PRINT A SINGLE BLANK LINE *
000795****************************************************************************
000797 WRITE-BLANK-LINE.
000798 MOVE SPACES TO LINE-RECORD.
000799 WRITE LINE-RECORD AFTER ADVANCING 1.
000800****************************************************************************
000801* START OF NEXT PAGE PROCEDURE TO ALLOW FOR LONG REPORTS *
000802****************************************************************************
000803 NEXT-PAGE.
000804 PERFORM PRINT-PAGE-TOTAL-PROC.
000805 MOVE ZEROS TO LINE-COUNT.
000806 PERFORM WRITE-BLANK-LINE.
000807 IF EOF-SWITCH = &quot;N&quot; THEN PERFORM HEADING-ROUTINE.
000808****************************************************************************
000809* START OF PRINT PAGE TOTAL PROCEDURE *
000810****************************************************************************
000811 PRINT-PAGE-TOTAL-PROC.
000812 PERFORM WRITE-BLANK-LINE.
000813 MOVE PAGE-TOTALCOST TO PRINT-PAGE-TOTAL-C.
000814* MOVE PAGE-TOTALSELL TO PRINT-PAGE-TOTAL-S.
000815* MOVE PRINT-PAGE-TOTALS TO LINE-RECORD.
000816****************************************************************************
000817* START OF CLOSE THE FILES AND END THE PROGRAM PROCEDURE *
000818****************************************************************************
000819 TERMINATE-PROGRAM.
000820 MOVE &quot;Y&quot; TO EOF-SWITCH.
000821 PERFORM NEXT-PAGE.
000822 WRITE LINE-RECORD AFTER ADVANCING 1.
000823 PERFORM WRITE-BLANK-LINE.
000824 MOVE FINAL-TOTALCOST TO PRINT-FINAL-TOTAL-C.
000825* MOVE FINAL-TOTALSELL TO PRINT-FINAL-TOTAL-S.
000826* MOVE PRINT-FINAL-TOTALS TO LINE-RECORD.
000827 WRITE LINE-RECORD AFTER ADVANCING 1.
000831 CLOSE INVENTORY-LISTING-OUT.
000832 CLOSE INVENTORY-FILE-IN.
000833 END PROGRAM INV-RPT.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top