Highlighted
Absent Member.
Absent Member.
2844 views

[archive] escape key

[Migrated content. Thread originally posted on 24 June 2005]

How do I program a screen so they can't use the escape key to get out of the screen? Help!!!
0 Likes
11 Replies
Highlighted
Absent Member.
Absent Member.

RE: [archive] escape key

Diana,

You might have to give a little bit more information so we can help you.

When you say 'screen' do you mean a character-based screen section screen? Or do you mean a graphical window? If it is the latter, is it a popup message box or dialog or a standard window?

What are you ACCEPTing? In the character-based environment you should be able to stop virtually anything to do with Escape.

In the graphical environment it depends if you have a CANCEL-BUTTTON defined for any of your push buttons.

Maybe a short code sample can help us identify your problem.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] escape key

I am sorry, I guess when I posted I was just flustrated. I am new to AcuCobol and I am using AcuBench so it is a graphical screen and no I don't have any cancel button on the screen. I have a menu item to logoff properly. I have programmed around everything else but the escape. The window type is standard. In my config file I have quit-mode = to a -2 to get rid of the X.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] escape key

Ahhh! AcuBench. OK!

We are Cobol old-timers so we never liked Acubench.

Looks like you will have to get your hands dirty and look at the code that AcuBench generates (something you will be doing a lot of!)

Have a look at program_name.evt which contains all the event stuff. There are a few paragraphs in there that might have the escape key code. Look at:
"Acu-screen_name-event"
"Screen-screen_name-event-rtn"
"Screen-screen_name-except-rtn"

Screens don't inherently exit with escape. They have to be programmed to do that. So something in the code that AcuBench has generated has added this 'feature'.

Someone with more knowledge of AcuBench could probably tell you if there is a property or something defined on the screen that enables this behaviour.

Hope this helps.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] escape key

That is interesting I wonder how I programmed the escape key. I will looking into some of the settings on the screen.

I am also a Cobol old-timer, but I am a HP Cobol programmer trying to program on the PC level. I am forcing myself to learn AcuBench. Since I have to yet learn another cobol I thought why not use AcuBench.

Thanks
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] escape key

Thanks setting the keystroke did work. At least now they can't get out in the middle of a transaction. Thanks for your help:)
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] escape key

Can anyone tell me if this same keystroke method can be used to trap out the Exit or "X" in the top right of a window?

In our application, CNTL+X, Menu-Exit, ESCAPE and the windows exit button are supposed to react the same, but the first 3 all manage to return codes we want like an exception of 27.

However the window exit button does not, if goes off into acu code and does it's own thing. The problem I have is even setting either the MSG-CLOSE or CMD-CLOSE I can't stop the program from doing a stop run. I try to initialize key-status and command-type but they are reset when acu does a screen accept and the program then does it's normal ending process.

With my exceptions of 27, I keep from letting exit program pushed get set to true. This works because the exception process is being done post the screen accept.

Any help or thoughts would be very much appreciated.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] escape key

msg-close is the event to look for, perhaps not all of your windows have an event procedure lloking for this, modify the programs so that they catche the msg-close event and moves an 'event-action-fail' to event-action if the msg-close happens.

Or consider executing the programs with the runtime -s option.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] escape key

This works perfectly, well almost anyway... Now that I've got that code in it does indeed trap that "X" exit action and stop it.

set event-action to event-action-fail

However, what do I need to do to get it so the events will flow normally after this is done? My X no longer will exit the program at all after that point.

I have tried setting event-action to event-action-normal adn even-action-terminate and they do not appear to be working. I tried event-action-continue as well.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] escape key

How about performing the same routine that occurs when a 27 is encountered.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] escape key

In our menu program we do not want the user to press escape.

So in the exception other for the screen we do

           IF KEY-STATUS = 27
              MOVE ZEROS TO KEY-STATUS
           END-IF
           IF  KEY-STATUS = 96
           AND WS-EXIT-PROG
           AND WS-LOG-OUT
               SET EXIT-PUSHED TO TRUE
           END-IF


Then on the actual screen when the user clicks the close X we do


       Screen1-Ev-Msg-Close.
           SET WS-LOG-OUT TO TRUE
           PERFORM VARYING WS-RP-INDEX FROM 1 BY 1
              UNTIL WS-RP-INDEX > Rp-Occurs
                 IF WS-RUNNING-PROGRAMS(WS-RP-INDEX) NOT = SPACES
                    SET WS-DONT-LOG-OUT TO TRUE
                 END-IF
           END-PERFORM
           IF WS-LOG-OUT
              SET WS-ESC-KEY   TO TRUE
              SET WS-EXIT-PROG TO TRUE
              SET EXIT-PUSHED  TO TRUE
              EXIT PARAGRAPH
           ELSE
              DISPLAY MESSAGE BOX
                      "Can't log out, programs running!"
                      TITLE IS "Logic"
                      TYPE  IS MB-OK
                      ICON  IS MB-WARNING-ICON
              MOVE ZERO TO KEY-STATUS
              MOVE EVENT-ACTION-FAIL TO EVENT-ACTION
              EXIT PARAGRAPH
           END-IF
           .



Hopefully makes sense.

Shaun
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] escape key

Thanks for the response, but I am trying to do the opposit of that and it appears to be reacting in an odd way. First, I'm running thin client, verion 7.2. Sometimes that matters, so I thought I'd note it.


Update!!!

this did work, I had a flag error causing my code not to fall through properly.

Merely using

set event-action to event-action-fail

did what I needed. I did not have to set the event-action to anything else to get the X working. Again, I had a flag that was not resetting, so my event-action-fail was always being run after the first time the flag was set.

thanks for your help.
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.