Rocket Software Homepage
Forum Home Forum Home > AccuTerm Knowledge Base (read only) > Scripting & Automation
  New Posts New Posts RSS Feed - Blocking user input while script execute
  FAQ FAQ  Forum Search   Register Register  Login Login

The AccuTerm forum has moved. Go to community.rocketsoftware.com to register for the new Rocket forum.

Forum LockedBlocking user input while script execute

 Post Reply Post Reply
Author
Message
danieldeslandes View Drop Down
Newbie
Newbie


Joined: May 03 2017
Location: Montreal
Status: Offline
Points: 7
Post Options Post Options   Thanks (0) Thanks(0)   Quote danieldeslandes Quote  Post ReplyReply Direct Link To This Post Topic: Blocking user input while script execute
    Posted: July 28 2017 at 7:53am
Hi,

I am executing the following script from my unidata program, the problem is that sometimes a user will input keys that will satisfy the INPUT CURRENT.DIRECTORY below and so the program will not capture the content output from the script.

What can I do to prevent that?  I tried ESC:'#' to lock keyboard and clearing the input stream with CLEARINPUT but I can still reproduce the problem... 

is there a better way to capture information from a script than using an INPUT statement?


script:

*----------------------------*
SCRIPT.GET.CURRENT.DIRECTORY:
*----------------------------*
*
   SCR = ""
   SCR=SCR:CHAR(25):'Dim WshShell, strCurDir'
   SCR=SCR:CHAR(25):'Set WshShell = CreateObject("WScript.Shell")'
   SCR=SCR:CHAR(25):'strCurDir    = WshShell.CurrentDirectory'
   SCR=SCR:CHAR(25):'InitSession.Output strCurDir & vbCR'

   PRINT ESC:STX:'R':SCR:CR:
   INPUT CURRENT.DIRECTORY:

Back to Top
danieldeslandes View Drop Down
Newbie
Newbie


Joined: May 03 2017
Location: Montreal
Status: Offline
Points: 7
Post Options Post Options   Thanks (0) Thanks(0)   Quote danieldeslandes Quote  Post ReplyReply Direct Link To This Post Posted: July 28 2017 at 11:16am
To be more clear,  the problem is that the user is entering data in a field and *might* hit "ENTER" twice, fast enough that the 2nd one will get captured by the INPUT CURRENT.DIRECTORY instead of the data being returned by the script.

I was able to lock keyboard before running the script with 
PRINT ESC:'[2h': ;*LOCK KEYBOARD
but the "ENTER" is done prior to that, so I was hoping doing CLEARINPUT before the script would clear it but no...

only way I was able to correct my problem is by doing this:
INPUTIF JUNK THEN JUNK = "" ELSE INPUT JUNK,1: FOR 1 THEN JUNK = ""

only problem I have with this is that it introduces a 1 second delay IF the user did not hit enter twice... I can leave with it for now but was looking for a better way of handling this without the wait...


thanks!


Back to Top
PSchellenbach View Drop Down
Admin Group
Admin Group

Moderator

Joined: December 15 2003
Location: United States
Status: Offline
Points: 2150
Post Options Post Options   Thanks (0) Thanks(0)   Quote PSchellenbach Quote  Post ReplyReply Direct Link To This Post Posted: July 28 2017 at 11:54am
Hi Daniel -

Locking the keyboard and clearing the typeahead is really the only way I can think of to prevent stray data from getting in. If you have a function to sleep for a fraction of a second, you might try inserting that between the keyboard lock and the CLEARINPUT. The INPUTIF ... FOR 1 is basically doing the same thing with a 1 second sleep. If you could do a 100ms sleep, that would probably be sufficient for any data in transit to arrive and get cleared by CLEARINPUT.

Thanks,

Pete

Back to Top
danieldeslandes View Drop Down
Newbie
Newbie


Joined: May 03 2017
Location: Montreal
Status: Offline
Points: 7
Post Options Post Options   Thanks (0) Thanks(0)   Quote danieldeslandes Quote  Post ReplyReply Direct Link To This Post Posted: July 28 2017 at 1:11pm
thanks for your help

I implemented a waiting loop and experimented with it. 

   CURRENT.TIME = SYSTEM(12) ;* current time in milliseconds
   LOOP
      IF SYSTEM(12) - CURRENT.TIME > 500 THEN
         CLEARDATA
         CLEARINPUT
         EXIT
      END
   REPEAT


Unfortunetaly, I was still able to get that carriage return to mess with my input...

It seems the INPUT is the only solution that works right now to capture any "extras" CR that might have been entered
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.03
Copyright ©2001-2019 Web Wiz Ltd.