Skip to main content

I have a need to provide a user input prompt that times out gracefully after a specific period.

I am using !EDIT.INPUT and that captures the input well.
What I am missing is a graceful method of setting a timeout for it.

I have attempted to use the AUTOLOGOUT command.
That does trigger a logoff (an ungraceful exit but an exit non the less).

Does anyone know of a way to assign an input timeout period for !EDIT.INPUT - or even just INPUT @ - that allows code to register and react to the non-input of data in a graceful manner?



------------------------------
Gregor Scott
Software Architect
Pentana Solutions Pty Ltd
Mount Waverley VIC AU
------------------------------

I have a need to provide a user input prompt that times out gracefully after a specific period.

I am using !EDIT.INPUT and that captures the input well.
What I am missing is a graceful method of setting a timeout for it.

I have attempted to use the AUTOLOGOUT command.
That does trigger a logoff (an ungraceful exit but an exit non the less).

Does anyone know of a way to assign an input timeout period for !EDIT.INPUT - or even just INPUT @ - that allows code to register and react to the non-input of data in a graceful manner?



------------------------------
Gregor Scott
Software Architect
Pentana Solutions Pty Ltd
Mount Waverley VIC AU
------------------------------

Gregor,

This honestly isn't something we do a lot anymore (I mostly do GUI and Web Programming), but would something like this work?  It's rough but it's just an idea.

       NCTR = 0 ; RESULT = ""
       PRINT @(-1)
       PRINT @(5,5):"WHAT?":
       LOOP
       UNTIL NCTR >= 30 OR RESULT # "" DO
          INPUTIF @(10,5):RESULT ELSE
             NAP 100
             NCTR += 1
          END
       REPEAT
       STOP
    END

The INPUTIF can include a THEN clause where you can manage validation, etc.

Like I said, it's just an idea, but it might spark something more.



------------------------------
Tyrel Marak
Technical Support Manager
Aptron Corporation
Florham Park NJ US
------------------------------

I have a need to provide a user input prompt that times out gracefully after a specific period.

I am using !EDIT.INPUT and that captures the input well.
What I am missing is a graceful method of setting a timeout for it.

I have attempted to use the AUTOLOGOUT command.
That does trigger a logoff (an ungraceful exit but an exit non the less).

Does anyone know of a way to assign an input timeout period for !EDIT.INPUT - or even just INPUT @ - that allows code to register and react to the non-input of data in a graceful manner?



------------------------------
Gregor Scott
Software Architect
Pentana Solutions Pty Ltd
Mount Waverley VIC AU
------------------------------

The optional WAITING argument was added to the BASIC INPUT statement at 12.1.1 release. It can be used to specify the numbers of seconds to wait before the INPUT statement times out. I'm not aware of any other built in way to do this prior to 12.1.



------------------------------
Neil Morris
Universe Advanced Technical Support
Rocket Software
------------------------------

I have a need to provide a user input prompt that times out gracefully after a specific period.

I am using !EDIT.INPUT and that captures the input well.
What I am missing is a graceful method of setting a timeout for it.

I have attempted to use the AUTOLOGOUT command.
That does trigger a logoff (an ungraceful exit but an exit non the less).

Does anyone know of a way to assign an input timeout period for !EDIT.INPUT - or even just INPUT @ - that allows code to register and react to the non-input of data in a graceful manner?



------------------------------
Gregor Scott
Software Architect
Pentana Solutions Pty Ltd
Mount Waverley VIC AU
------------------------------

Hi Gregor,

The basic command INPUTIF can be used to to give you a timeout.
INPUTIF is a variant of the standard INPUT statement.
On my version of UniVerse you need to HELP BASIC INPUT to see the syntax for INPUTIF, and the help for INPUTIF incorrectly refers back to itself.  
Unforunately there are some nice features in !EDIT.INPUT that are not available in any of the INPUT commands, so this solution may not suit you.

Regards,



------------------------------
Bruce Philp
Senior Services Consultant
Meier Business Systems PTY LTD
Carnegie VIC AU
------------------------------

Gregor,

This honestly isn't something we do a lot anymore (I mostly do GUI and Web Programming), but would something like this work?  It's rough but it's just an idea.

       NCTR = 0 ; RESULT = ""
       PRINT @(-1)
       PRINT @(5,5):"WHAT?":
       LOOP
       UNTIL NCTR >= 30 OR RESULT # "" DO
          INPUTIF @(10,5):RESULT ELSE
             NAP 100
             NCTR += 1
          END
       REPEAT
       STOP
    END

The INPUTIF can include a THEN clause where you can manage validation, etc.

Like I said, it's just an idea, but it might spark something more.



------------------------------
Tyrel Marak
Technical Support Manager
Aptron Corporation
Florham Park NJ US
------------------------------

Thanks @Tyrel Marak 

I have not worked with the INPUTIF much, so I tried out your example.
The INPUTIF statement blocks the moment there is at least 1 character in the input buffer, so the "ELSE" clause is not used and the "THEN" clause is only run once the <ENTER> key is pressed.

The challenge I have is a need to timeout for the entire input session, so it is not quite appropriate for my requirements.



------------------------------
Gregor Scott
Software Architect
Pentana Solutions Pty Ltd
Mount Waverley VIC AU
------------------------------

The optional WAITING argument was added to the BASIC INPUT statement at 12.1.1 release. It can be used to specify the numbers of seconds to wait before the INPUT statement times out. I'm not aware of any other built in way to do this prior to 12.1.



------------------------------
Neil Morris
Universe Advanced Technical Support
Rocket Software
------------------------------

Thanks @Neil Morris 

We are on 11.3 variants at the moment.
That feature alone will not get us into the 12.x stream but it is good to know there is something available.



------------------------------
Gregor Scott
Software Architect
Pentana Solutions Pty Ltd
Mount Waverley VIC AU
------------------------------

Hi Gregor,

The basic command INPUTIF can be used to to give you a timeout.
INPUTIF is a variant of the standard INPUT statement.
On my version of UniVerse you need to HELP BASIC INPUT to see the syntax for INPUTIF, and the help for INPUTIF incorrectly refers back to itself.  
Unforunately there are some nice features in !EDIT.INPUT that are not available in any of the INPUT commands, so this solution may not suit you.

Regards,



------------------------------
Bruce Philp
Senior Services Consultant
Meier Business Systems PTY LTD
Carnegie VIC AU
------------------------------

I am working on using the !GET.KEY subroutine in a loop and providing a simple input edit functionality with a timeout.
I got some inspiration from a couple of the user exits in the APP.PROGS library in the UV account ( the comments and variables are in French but the logic gave me some pointers).



------------------------------
Gregor Scott
Software Architect
Pentana Solutions Pty Ltd
Mount Waverley VIC AU
------------------------------

I am working on using the !GET.KEY subroutine in a loop and providing a simple input edit functionality with a timeout.
I got some inspiration from a couple of the user exits in the APP.PROGS library in the UV account ( the comments and variables are in French but the logic gave me some pointers).



------------------------------
Gregor Scott
Software Architect
Pentana Solutions Pty Ltd
Mount Waverley VIC AU
------------------------------

Have you seen GitHub - MarcusAureliusRhodes/AnyKey: Putting the ghost in the (Pick/Multivalue) machine since 1994

GitHub remove preview
GitHub - MarcusAureliusRhodes/AnyKey: Putting the ghost in the (Pick/Multivalue) machine since 1994
(Putting the ghost in the {Pick/Multivalue} machine since 1994) What you'll find here is some of my personal Pick Basic source code (and maybe some necessary data, too). I call this particular project AnyKey. AnyKey's purpose is to enable Pick programs to respond to any key (or combination of keys) on the keyboard, no matter what terminal emulation or terminal emulator is being used.
View this on GitHub >

?



------------------------------
Marcus Rhodes
marcus1@thinqware.com
------------------------------

I am working on using the !GET.KEY subroutine in a loop and providing a simple input edit functionality with a timeout.
I got some inspiration from a couple of the user exits in the APP.PROGS library in the UV account ( the comments and variables are in French but the logic gave me some pointers).



------------------------------
Gregor Scott
Software Architect
Pentana Solutions Pty Ltd
Mount Waverley VIC AU
------------------------------
Hello Dear All,

Just another way to control parameters using external VOC.

Create VOC query to store/maintain parameters as shown in example below:

:EV XHB.BB.HELPDESK.FA.CORR.EXPORT.PARAMETERS

001: PA XHB.BB.HELPDESK.FA.CORR.EXPORT.PARAMETERS
002: DISPLAY ***********************************************************
003: DISPLAY THIS IS SETUP PARAMETERS FOR XHB.BB.HELPDESK.FA.CORR.EXPORT
004: DISPLAY ***********************************************************
005: DATA 01/01/17
006: DATA 06/30/25
007: DATA FA,ADM,AR

From your main query call parameters VOC Query to use those parameters as shown in example below.

:EV XHB.BB.HELPDESK.FA.CORR.EXPORT.V4

012: ** =============================================================
013: XHB.BB.HELPDESK.FA.CORR.EXPORT.PARAMETERS
014: ** =============================================================
015: * <>
016: * <>
017: * <>
018: ** =============================================================
019: *


Kind Regards
Hanumant Borate

I have a need to provide a user input prompt that times out gracefully after a specific period.

I am using !EDIT.INPUT and that captures the input well.
What I am missing is a graceful method of setting a timeout for it.

I have attempted to use the AUTOLOGOUT command.
That does trigger a logoff (an ungraceful exit but an exit non the less).

Does anyone know of a way to assign an input timeout period for !EDIT.INPUT - or even just INPUT @ - that allows code to register and react to the non-input of data in a graceful manner?



------------------------------
Gregor Scott
Software Architect
Pentana Solutions Pty Ltd
Mount Waverley VIC AU
------------------------------

You could also look at this routine on the PickWiki website:

https://www.pickwiki.com/index.php/InputWait

Cheers,

Brian



------------------------------
Brian Speirs
Senior Analyst - Information Systems
Self Registered
Wellington NZ
------------------------------

You could also look at this routine on the PickWiki website:

https://www.pickwiki.com/index.php/InputWait

Cheers,

Brian



------------------------------
Brian Speirs
Senior Analyst - Information Systems
Self Registered
Wellington NZ
------------------------------

This is an interesting routine.

This is what I put together, using the !GET.KEY function to obtain each key in it's entirety.

subroutine GET_INPUT( the.TIMEOUT, the.LENGTH, the.INPUT, the.STATUS)
* Use !GET.KEY in a loop to get input, with a timeout
*
* The value of the.INPUT is not displayed, and is removed
* This routine focuses on capturing NEW input and is NOT an editor
* for existing details.

* the.STATUS :  0 = All good - user entered a value
*               1 = Badness happened - no input
*               2 = Input timeout

$include UNIVERSE.INCLUDE ATFUNCTIONS.H
$include    UNIVERSE.INCLUDE TERMINFO

nap_TIME = 10  ;* Milliseconds
the.INPUT = ''
the.STATUS = 0

* When do we abandon this input attempt?
end_TIME = system(99) + the.TIMEOUT
loop
   * Check if there is anything in the input buffer
   input keys_waiting, -1
   if not(keys_waiting) then
      * No key pressed, get busy waiting
      loop
         nap nap_TIME
         input keys_waiting, -1
         if keys_waiting then
            * We have something to do, stop waiting
            exit
         end else
            * Check if we have timed out
            if system(99) > end_TIME then
               * Exit our wait loop
               the.STATUS = 2
               exit
            end
         end
      repeat
      * If we have timed out exit our input loop
      if the.STATUS = 2 then exit
   end

   * get the key waiting on the input buffer
   code.KEY = ''
   in.KEY = ''
   call !GET.KEY( in.KEY, code.KEY)

   begin case
      case code.KEY = 0
         * Normal keys
         if in.KEY > char(31) and in.KEY < char(127) then
            if len(the.INPUT) < the.LENGTH then
               the.INPUT = the.INPUT : in.KEY
               crt in.KEY:
            end else crt BELL:
         end else crt BELL:
         
      case in.KEY = KEY.BACKSPACE
         * Remove a character
         if len(the.INPUT) then
            the.INPUT = the.INPUT[1,len(the.INPUT)-1]
            * Backspace 1 char, delete 1 char
            crt @(IT$CUB): @(IT$DCH):
         end else crt BELL:
         
      case in.KEY = char(10) or in.KEY = char(13)
         * user has <ENTER>ed their value!
         exit
         
      case 1
         * nope - these are not valid
         crt BELL:
   end case

   * Check if we have timed out
   * Cannot have a busy keyboard stop the timing checks
   if system(99) >= end_TIME then
      * Times up - Exit our input loop
      the.STATUS = 2
      exit
   end
repeat
if the.STATUS = 2 then the.INPUT = ''

return




------------------------------
Gregor Scott
Software Architect
Pentana Solutions Pty Ltd
Mount Waverley VIC AU
------------------------------