I have been looking for the way to tell if a key has been pressed without having to wait on an accept.
Like when a game is running, it stays active doing stuff instead of waiting for a key.
I tried CBL_READ_KBD_CHAR, but that was not what I wanted.
I'm trying to do something if it takes too long for a reply. I found the TIMEOUT option of accept but don't know how to work it. [ TIMEOUT|TIME-OUT AFTER { integer-5 } ] What goes into integer-5 for what length of time?
Also trying to build in an interupt from the user when the program is busy doing something else.
I'm looking for something SIMPLE.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
Anonymous
-
2022-02-27
From the PG 7.8.1.4 : -
The TIMEOUT option will cause the ACCEPT to wait no more than the specified number of
seconds for input. The wait count may be specified as a positive integer or a numeric data
item with a positive value.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Michael ,
this is the simplest way I use to make the program do things and stop those things when the user presses a key.
note in this case with accept omitted keys corresponding to letters or numbers are not allowed.
let me know if this is what you wanted.
>>SOURCEFORMATISFREEREPLACE==:BCOL:==BY==withBACKGROUND-COLOR====:FCOL:==BY==FOREGROUND-COLOR==.IDDIVISION.PROGRAM-ID.ED00TESTisinitial.*>************************************************************************************>************************************************************************************ENVIRONMENTDIVISION.CONFIGURATIONSECTION.SPECIAL-NAMES.CRTSTATUSISws-KEY.DATADIVISION.WORKING-STORAGESECTION.77K-ENTERPIC9(04)VALUE0000.77K-F1PIC9(04)VALUE1001.77K-F2PIC9(04)VALUE1002.77K-F3PIC9(04)VALUE1003.77K-F4PIC9(04)VALUE1004.77K-F5PIC9(04)VALUE1005.77K-F6PIC9(04)VALUE1006.77K-F7PIC9(04)VALUE1007.77K-F8PIC9(04)VALUE1008.77K-F9PIC9(04)VALUE1009.77K-F10PIC9(04)VALUE1010.77K-F11PIC9(04)VALUE1011.77K-F12PIC9(04)VALUE1012.*>Exceptionkeys-PIC9(04)VALUEs2xxx.77K-PAGEUPPIC9(04)VALUE2001.77K-PAGEDOWNPIC9(04)VALUE2002.77K-UPPIC9(04)VALUE2003.77K-DOWNPIC9(04)VALUE2004.77K-ESCAPEPIC9(04)VALUE2005.77K-PRINTPIC9(04)VALUE2006.77K-TABPIC9(04)VALUE2007.77K-BACKTABPIC9(04)VALUE2008.77K-LEFTPIC9(04)VALUE2009.77K-RIGHTPIC9(04)VALUE2010.*>Thefollowingkeysare*only*returnedonACCEPTOMITTED77K-INSERTPIC9(04)VALUE2011.77K-DELETEPIC9(04)VALUE2012.77K-BACKSPACEPIC9(04)VALUE2013.77K-HOMEPIC9(04)VALUE2014.77K-ENDPIC9(04)VALUE2015.*>Inputvalidation-VALUEs8xxx77K-NO-FIELDPIC9(04)VALUE8000.*>NODATAFROMACCEPTex.atimeoutispassed(also8001)77K-TIMEOUTPIC9(04)VALUE8001.*>Othererrors-PIC9(04)VALUEs9xxx77K-FATALPIC9(04)VALUE9000.77K-MAXFIELDPIC9(04)VALUE9001.01ws-KEYPIC9(0004)VALUE9999.01wDAYpicx(08).01wStringpicx(60).01Date-Timepicx(20).01wTimepicx(08).*>****************************************************************************************>PROCEDUREDIVISION*>***************************************************************************************PROCEDUREDIVISION.*>setsinordertodetectthePgUp,PgDn,PrtSc(screenprint),Esckeyssetenvironment'COB_SCREEN_EXCEPTIONS'TO'Y'.setenvironment'COB_SCREEN_ESC'TO'Y'.display''at0101withblankscreenend-display.display" ESC to exit "at010001:BCOL:0:FCOL:7.LoopAccept.*>****************************************************************************>looptodisplaythetimeevery1sec*>***************************************************************************performforeveracceptomittedat2580withautotimeout1end-accept*>acceptwithoutvalueattimeoutreturns"8001"toCRT-STATUSifws-KEYnot=K-TIMEOUTexitperformend-if*>hereyoucandowhateveryouneed..inthiscasewedisplaythetimeacceptwDayfromdateYYYYMMDDacceptwTimefromtimestringwDay(1:4)'.'wDay(5:2)'.'wDay(7:2)''wTime(1:2)':'wTime(3:2)':'wTime(5:2)delimitedbysizeintoDate-TimedisplayDate-Timeat001001:BCOL:0:FCOL:7end-displayend-perform*>akeywaspressed.displaywhichkeywaspressed?evaluatews-KEYwhenK-ESCAPEgoEndProgramwhenotherstring"key pressed is "ws-KEYdelimitedbysizeintowStringdisplaywStringat003001:BCOL:0:FCOL:7end-displayend-evaluategotoLoopAcceptcontinue.EndProgram.STOPRUNWITHNORMALSTATUS.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
OK. That works for the most part.
I added this to my MYMENU0001 program and about 5 more lines of code elsewhere and am getting the results I want.
I accepted into a screen section item and it works.
Last edit: Michael F Gleason 2022-02-27
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have been looking for the way to tell if a key has been pressed without having to wait on an accept.
Like when a game is running, it stays active doing stuff instead of waiting for a key.
I tried CBL_READ_KBD_CHAR, but that was not what I wanted.
I'm trying to do something if it takes too long for a reply. I found the TIMEOUT option of accept but don't know how to work it. [ TIMEOUT|TIME-OUT AFTER { integer-5 } ] What goes into integer-5 for what length of time?
Also trying to build in an interupt from the user when the program is busy doing something else.
I'm looking for something SIMPLE.
From the PG 7.8.1.4 : -
seconds for input. The wait count may be specified as a positive integer or a numeric data
item with a positive value.
Hi Michael ,
this is the simplest way I use to make the program do things and stop those things when the user presses a key.
note in this case with accept omitted keys corresponding to letters or numbers are not allowed.
let me know if this is what you wanted.
OK. That works for the most part.
I added this to my MYMENU0001 program and about 5 more lines of code elsewhere and am getting the results I want.
I accepted into a screen section item and it works.
Last edit: Michael F Gleason 2022-02-27