Highlighted
Frequent Contributor.
Frequent Contributor.
198 views

ACCEPT "screen name" ON ESCAPE...

Jump to solution

Hello,

I recently started using MF Visual COBOL and importing old programs I've done using MS COBOL back in 1995.

I noticed that some of screen section statements aren't functional under MF Cobol especially the ON ESCAPE condition in ACCEPT statement,

Any idea how to make it work??

** below is the a sample program that use Accept... ON ESCAPE..

IDENTIFICATION DIVISION.
PROGRAM-ID. NEHMECHP as "NEHMECHP".
AUTHOR. NEHME YOUNES.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.

SELECT F-CHP ASSIGN TO DISK

ORGANIZATION IS INDEXED
ACCESS MODE IS DYNAMIC
LOCK MODE IS AUTOMATIC
RECORD KEY IS CHPNUM.
DATA DIVISION.
FILE SECTION.
FD F-CHP
BLOCK CONTAINS 105 RECORDS
RECORD CONTAINS 39 CHARACTERS
LABEL RECORDS ARE STANDARD
VALUE OF FILE-ID IS "CHPBNY.DAT".
01 RCHP.
02 CHPNUM.
03 SUB-LDGR.
04 GEN-LDGR PIC 99.
04 NUM PIC 9.
03 CHAPTER PIC 9.
02 CHPNAME PIC X(35).
*****
WORKING-STORAGE SECTION.
77 SW PIC X VALUE SPACE.
77 SW1 PIC X VALUE SPACE.
77 MSG PIC X(40).
77 W-NAME PIC X(13).
77 NAME2 PIC X(16).
01 W-RCHP.
02 W-CHPNUM.
03 W-SUB-LDGR.
04 W-GEN-LDGR PIC 99.
04 W-NUM PIC 9.
03 W-CHAPTER PIC 9.
02 W-CHPNAME PIC X(35).
01 DTW.
02 YY PIC 99.
02 MM PIC 99.
02 DD PIC 99.
01 TMW.
02 HHH PIC 99.
02 MMM PIC 99.
02 SSS PIC 99.
01 OPTION.
02 OPT PIC A.
88 MANTA VALUES "M", "m".
88 DELET VALUES "D", "d".
88 QUIT VALUES "Q", "q".
88 NEXTT VALUE " ".
02 SURE PIC A.
88 YES VALUES "Y", "y".
***************************************************************
* THE SCREEN SECTION *
***************************************************************
* MAIN SCREEN *
***************************************************************
SCREEN SECTION.
01 SCRM.
02 SCR-M1.
04 LINE 2 COLUMN 1 PIC X(13) REVERSE-VIDEO USING W-NAME.
02 SCRM-M1.
03 COLUMN 29 VALUE "L ACCOUNTING  SYSTEM".
03 COLUMN 68 VALUE "DATE:" REVERSE-VIDEO.
03 COLUMN 73 PIC 99 REVERSE-VIDEO USING DD.
03 COLUMN 75 VALUE "/" REVERSE-VIDEO.
03 COLUMN 76 PIC 99 REVERSE-VIDEO USING MM.
03 COLUMN 78 VALUE "/" REVERSE-VIDEO.
03 COLUMN 79 PIC 99 REVERSE-VIDEO USING YY.
03 LINE 3 COLUMN 1 VALUE "Company Name" REVERSE-VIDEO.
03 COLUMN 31 VALUE "CONTROL CHAPTERS".
02 SCR-M2.
03 COLUMN 68 VALUE "TIME:" REVERSE-VIDEO.
03 COLUMN 73 PIC 99 REVERSE-VIDEO FROM HHH.
03 COLUMN 75 VALUE "|" REVERSE-VIDEO.
03 COLUMN 76 PIC 99 REVERSE-VIDEO FROM MMM.
03 COLUMN 78 VALUE "|" REVERSE-VIDEO.
03 COLUMN 79 PIC 99 REVERSE-VIDEO FROM SSS.
*
*********************
01 SCR1.
02 SCR1-2.
03 LINE 10 COLUMN 20 VALUE "CHAPTER CODE:".
03 COLUMN 35 PIC 9(2) USING W-GEN-LDGR BLANK WHEN ZERO AUTO.
03 COLUMN PLUS 1 PIC 9 USING W-NUM BLANK WHEN ZERO AUTO.
03 COLUMN PLUS 1 PIC 9 USING W-CHAPTER BLANK WHEN ZERO AUTO.
02 SCR1-3.
03 LINE 13 COLUMN 20 PIC X(16) FROM NAME2.
03 COLUMN 37 PIC X(35) USING CHPNAME AUTO.
02 SCR1-4.
03 LINE 19 COLUMN 29 VALUE " ".
02 SCR1-5.
03 SCRD-5.
04 LINE 22 COLUMN 2 VALUE "Rtrn" HIGHLIGHT.
04 COLUMN 6 VALUE "=NEXT".
04 COLUMN 30 VALUE "M" HIGHLIGHT.
04 COLUMN 31 VALUE "aintain".
04 COLUMN 50 VALUE "D" HIGHLIGHT.
04 COLUMN 51 VALUE "elete".
04 COLUMN 71 VALUE "Q" HIGHLIGHT.
04 COLUMN 72 VALUE "uit".
03 SCRA-5.
04 LINE 22 COLUMN PLUS 1 PIC A TO OPT AUTO.

*************************************************************
* MESSAGES SCREENS *
*************************************************************
01 SCRMS.
02 SCRM-1.
03 LINE 21 COLUMN 30 VALUE "Cann't delete now !!!." HIGHLIGHT
BLINK.
02 SCRM-2.
03 LINE 21 COLUMN 30 VALUE "Cann't escape in this case !!!."
HIGHLIGHT BLINK.
02 SCRM-3.
03 LINE 21 COLUMN 30 VALUE "ARE YOU SURE (Y/N) :" HIGHLIGHT.
03 COLUMN PLUS 1 PIC A TO SURE AUTO.
02 SCRM-5.
03 LINE 21 BLANK LINE.
02 SCRM-6.
03 LINE 21 COLUMN 30 VALUE "I AM OUT NOW !!!." BLINK.
02 SCRM-7.
03 LINE 21 COLUMN 30 VALUE "Check the chapter # !!."
HIGHLIGHT BLINK.
02 SCRM-8.
03 LINE 21 COLUMN 30 VALUE "Nothing to maintain !!."
HIGHLIGHT BLINK.
02 SCRM-9.
03 LINE 21 COLUMN 16 VALUE "WARNING.." REVERSE-VIDEO BLINK.
03 LINE 21 COLUMN 25 PIC X(40) HIGHLIGHT FROM MSG.
*************************************************************
* THE LINES SCREEN *
*************************************************************
01 SCRLINE.
02 SCRL.
03 LINE 1 PIC X(80) FROM ALL " " REVERSE-VIDEO.
03 LINE 4 PIC X(80) FROM ALL " " REVERSE-VIDEO.
03 LINE 20 PIC X(80) FROM ALL " " REVERSE-VIDEO.
03 LINE 24 PIC X(80) FROM ALL " " REVERSE-VIDEO.
01 NEW-COLOR.
03 BLANK SCREEN FOREGROUND-COLOR 2 BACKGROUND-COLOR 0.
************************************************************
************************************************************
* THE PROCEDURE DIVISION *
************************************************************
************************************************************
PROCEDURE DIVISION.
STR.


ACCEPT DTW FROM DATE.
ACCEPT TMW FROM TIME.
DISPLAY NEW-COLOR.

BEGIN.

* OPEN OUTPUT F-CHP CLOSE F-CHP STOP RUN.
OPEN I-O F-CHP.

DIS1.

MOVE ZEROES TO CHPNUM W-CHPNUM
MOVE SPACES TO CHPNAME OPT SURE
DISPLAY NEW-COLOR.
MOVE " UNDEFINED " TO W-NAME
DISPLAY SCR-M1.
MOVE "CHAPTER NAME :" TO NAME2.
DISPLAY SCRM.
DISPLAY SCRL.
DISPLAY SCR1.

REAC.

MOVE ZEROES TO CHPNUM W-CHPNUM
ACCEPT TMW FROM TIME
DISPLAY SCR-M2.
ACCEPT SCR1-2
IF W-GEN-LDGR = 0
MOVE " " TO SW
MOVE "OPTIONS LINE" TO W-NAME
GO CHECK-OPTION.
DISPLAY SCRM-5.
MOVE W-GEN-LDGR TO GEN-LDGR
PERFORM SEARCH-G.

CHK1.

MOVE W-SUB-LDGR TO SUB-LDGR
PERFORM SEARCH-S.

CHK2.

MOVE SPACES TO CHPNAME
MOVE W-CHPNUM TO CHPNUM
GO SEARCH-C.

****************************************************************
* SEARCH PARAGRAPHS *
****************************************************************
SEARCH-G.

READ F-CHP
INVALID KEY
MOVE "YOU MUST DEFINE GENERAL LEDGER" TO MSG
DISPLAY SCRM-9
MOVE "GENERAL LEDGER :" TO NAME2
MOVE ZEROES TO W-NUM W-CHAPTER
GO TAABEH.

SEARCH-G-EXIT.

EXIT.

SEARCH-S.

READ F-CHP
INVALID KEY
MOVE "YOU MUST DEFINE SUB-LEDGER" TO MSG
DISPLAY SCRM-9
MOVE "SUB-LEDGER :" TO NAME2
MOVE ZEROES TO W-CHAPTER
GO TAABEH.

SEARCH-S-EXIT.

EXIT.

SEARCH-C.

READ F-CHP
INVALID KEY
GO TAABEH.
MOVE "RETREIVE" TO W-NAME
DISPLAY SCR-M1
DISPLAY SCR1-3.
MOVE "R" TO SW
GO CHECK-OPTION.

*

TAABEH.

MOVE "W" TO SW
MOVE "ADDIND" TO W-NAME.
DISPLAY SCR-M1.


****************************************************************
REAC1.

ACCEPT TMW FROM TIME
DISPLAY SCR-M2.
DISPLAY SCR1-2
DISPLAY SCR1-3.
ACCEPT SCR1-3 ON ESCAPE GO RECK.
IF CHPNAME = " " GO REAC1.
*******
CHECK-OPTION.

DISPLAY SCR-M1
ACCEPT TMW FROM TIME
DISPLAY SCR-M2.
MOVE SPACE TO OPT.
DISPLAY SCR1-5.
ACCEPT SCRA-5.

evaluate true

when MANTA

MOVE "MAINTAIN" TO W-NAME
DISPLAY SCR-M1
GO MAINT

when  DELET

MOVE "DELETING" TO W-NAME
DISPLAY SCR-M1
GO DEL

when QUIT

MOVE "QUITTING" TO W-NAME
DISPLAY SCR-M1
GO CHECK-TO-SAVE

when NEXTT

MOVE "WRITING " TO W-NAME
DISPLAY SCR-M1
GO CHECK-TO-SAVE

when other

GO CHECK-OPTION.

end-evaluate.

***********
MAINT.

IF SW = "R"
GO REAC1.
IF SW = "W"
GO REAC
ELSE
DISPLAY SCRM-8
GO CHECK-OPTION.
***********

DEL.

ACCEPT TMW FROM TIME
DISPLAY SCR-M2.

IF SW = "W" OR SW = " "
DISPLAY SCRM-1
GO CHECK-OPTION.
IF SW = "R"
DISPLAY SCRM-3
ACCEPT SCRM-3
IF YES
DELETE F-CHP RECORD.
ACCEPT TMW FROM TIME
GO DIS1
GO REAC.

***********

RECK.

ACCEPT TMW FROM TIME
DISPLAY SCR-M2.
IF SW = "R"
DISPLAY SCRM-2
GO REAC1.
IF SW = "W"
GO REAC.

***********

CHECK-TO-SAVE.

IF SW = "R"
REWRITE RCHP.
IF SW = "W"
WRITE RCHP
INVALID KEY
DISPLAY SCRM-7
GO DIS1.
IF QUIT
GO EX-IT
ELSE
GO DIS1.

EX-IT.

DISPLAY SCRM-6.
CLOSE F-CHP.
DISPLAY NEW-COLOR.
goback.

EXIT PROGRAM.

end program NEHMECHP.

 

0 Likes
1 Solution

Accepted Solutions
Highlighted
Micro Focus Expert
Micro Focus Expert

Re: ACCEPT "screen name" ON ESCAPE...

Jump to solution

@nyounes 

The ON ESCAPE clause is only executed when the ACCEPT is terminated with a condition that would have a non-zero key-type if your program had a CRT STATUS clause defined. It is not necessary for you to add that but it is useful in determining the reason that an ACCEPT terminated.

I was able to get the ON ESCAPE clause to execute by running the ADISCF utility and setting the option to enable user function keys to terminate an accept. Then, when I ran your program if I pressed Page Up that executed the code.

I hope that helps,

Gael

View solution in original post

0 Likes
8 Replies
Highlighted
Micro Focus Expert
Micro Focus Expert

Re: ACCEPT "screen name" ON ESCAPE...

Jump to solution

I found that this program compiled cleanly using Visual COBOL, with the exception of the following lines:

when other

GO CHECK-OPTION.

end-evaluate.

...where there is a period at the end of the GO line.  This terminates the surrounding evaluate statement, and therefore invalidates the following end-evaluate.

If I remove this period, then the program compiles cleanly.

 

0 Likes
Highlighted
Frequent Contributor.
Frequent Contributor.

Re: ACCEPT "screen name" ON ESCAPE...

Jump to solution

The PROGRAM-ID, goback, end program and evaluate were modified recently under visual cobol. And yes you are right about the "." after when other.

but the main issue is that the Accept .... ON ESCAPE isn't functional.

***attached the original program

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

Re: ACCEPT "screen name" ON ESCAPE...

Jump to solution

I think I misunderstood.  When you said that the ESCAPE clause 'isn't functional', I was assuming that you meant that the program does not compile cleanly.

Did you actually mean that it doesn't execute correctly at run-time?

If so, can you explain what behaviour you would expect to see when you run the program?  I see a screen, which seems to be correctly displayed, but I don't know what I need to do to reproduce the problem.

 

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

Re: ACCEPT "screen name" ON ESCAPE...

Jump to solution

@nyounes 

The ON ESCAPE clause is only executed when the ACCEPT is terminated with a condition that would have a non-zero key-type if your program had a CRT STATUS clause defined. It is not necessary for you to add that but it is useful in determining the reason that an ACCEPT terminated.

I was able to get the ON ESCAPE clause to execute by running the ADISCF utility and setting the option to enable user function keys to terminate an accept. Then, when I ran your program if I pressed Page Up that executed the code.

I hope that helps,

Gael

View solution in original post

0 Likes
Highlighted
Frequent Contributor.
Frequent Contributor.

Re: ACCEPT "screen name" ON ESCAPE...

Jump to solution
Hi Robert,
Yes, it compiles with no errors and works fine, except when you press ESCAPE it does nothing.
ON ESCAPE condition is being used when adding "Chapter Description" in SCR1-3, if you press it, it should send you back to "Chapter Code" in SCR1-2.

REAC1.
ACCEPT TMW FROM TIME
DISPLAY SCR-M2.
DISPLAY SCR1-2
DISPLAY SCR1-3.
ACCEPT SCR1-3 ON ESCAPE GO RECK.
IF CHPNAME = " " GO REAC1.
0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

Re: ACCEPT "screen name" ON ESCAPE...

Jump to solution

Were you able to try Gael's suggestion in a previous note?  We think that you need to use the ADISCF utility in order to enable this functionality.

Unfortunately I posted before seeing Gael's response...

 

Highlighted
Frequent Contributor.
Frequent Contributor.

Re: ACCEPT "screen name" ON ESCAPE...

Jump to solution

Hi Gael,

Thank you for your reply. Mentioning the ADISCF gave me idea to enable ESC and Function Keys by using the call x"AF"  function.

It's working now, enabled ESC key to step back in fields.

0 Likes
Highlighted
Frequent Contributor.
Frequent Contributor.

Re: ACCEPT "screen name" ON ESCAPE...

Jump to solution
Yes Robet, Gael highlighted the idea of enabling/disabling ESC and F Keys.
it worked, I attached the modified program, please feel free to have a look at it.
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.