Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

Keystroke test

 [1/11] from: tim::johnsons-web::com at: 5-Aug-2000 9:41


Hey Y'All: If I run a rebol script in a forever loop, I have to shut rebol down to terminate the script. Is there a rebol function to test for a keystroke, and if one found, redirect control? (sort of like kbhit() would do in "C"). Thanks -Tim

 [2/11] from: tim:johnsons-web at: 6-Aug-2000 15:53


Hey Y'All: If I run a rebol script in a forever loop, I have to shut rebol down to terminate the script. Is there a rebol function to test for a keystroke, and if one found, redirect control? (sort of like kbhit() would do in "C"). Thanks -Tim

 [3/11] from: allenk:powerup:au at: 7-Aug-2000 11:47


Hi Tim, Is it running as a view window or console? If it is running in the console you can use Escape key to halt If it is running in a view window you can add you own event handler and call 'do-events in the loop to give view a chance to get the event. (haven't tested this) There is an entry in the FAQ for adding an event-handler http://www.rebolforces.com/faq/view-faq.html You might might be able to avoid all that, by putting a label on the form with a shortcut key. layout [text #"q" "press q to halt" [halt]] Hope some of that helps.. Cheers, Allen K ----- Original Message ----- From: <[tim--johnsons-web--com]> To: <[ally--rebol--com]> Cc: <[ally--rebol--com]>

 [4/11] from: tim:johnsons-web at: 7-Aug-2000 13:05


Hi Gabriele : Thanks so much! As always, you are concise, thorough and further educate me. :) Regards Tim At 09:22 PM 8/7/00 +0200, you wrote:

 [5/11] from: tim:johnsons-web at: 6-Aug-2000 20:06


Thanks Allen: I was aware of that feature :) BTW: This is core: next question: Can the escape key sequence be intercepted so that rebol can then provide a prompt for additional input, rather than immediately terminating? P.S. I hope the enterprise is going well. Tim At 11:47 AM 8/7/00 +1000, you wrote:

 [6/11] from: al:bri:xtra at: 7-Aug-2000 16:16


> Is there a rebol function to test for a keystroke, and if one found,
redirect control? IIRC this was discussed some time back. Basically open the console as a port and write something like: while [empty? console] [ do MyStuff ] I don't recall the exact details. Andrew Martin ICQ: 26227169 http://members.xoom.com/AndrewMartin/

 [7/11] from: jkinraid:clear at: 7-Aug-2000 19:43


[tim--johnsons-web--com] wrote:
> Thanks Allen: > I was aware of that feature :)
<<quoted lines omitted: 4>>
> rebol can then provide a prompt for additional input, rather > than immediately terminating?
system/console/break: false Julian Kinraid

 [8/11] from: agem:crosswinds at: 7-Aug-2000 14:11


some lines i use: [ if not value? 'cons [cons: open/binary [scheme: 'console]] ;if you want to wait for a key: system/console/break: false wait cons system/console/break: true {next: do-key is my handler function, rest ist "gimme a key". i think without a key 'none ? ever 'wait 'ed :) } do-key to char! pick cons 1 ; get and handle the key ] Volker

 [9/11] from: tim:johnsons-web at: 7-Aug-2000 9:05


From rebol/core, I would like to run a program in a forever loop that will process (something) until any of a set of keystrokes are intercepted. here is the code I have written, but doesn't work. forever [ system/console/keys: "abcdef" either [system/console/keys = none][] [ print "input: " system/console/keys break ] ] ; In other words I'd like to break out of the loop if any of ; a set of keystrokes are intercepted, not just the ; escape key. Thanks Tim

 [10/11] from: g:santilli:tiscalinet:it at: 7-Aug-2000 21:22


Hello [tim--johnsons-web--com]! On 07-Ago-00, you wrote: t> From rebol/core, I would like to run a program in t> a forever loop that will process (something) until t> any of a set of keystrokes are intercepted.
>> con: open/binary console:/ >> forever [
[ ; do-my-stuff [ if ch: pick con 1 [ [ print ["broken with:" to-char ch "(" ch ")"] [ break [ ] [ ] broken with: b ( 98 ) Regards, Gabriele. -- Gabriele Santilli <[giesse--writeme--com]> - Amigan - REBOL programmer Amiga Group Italia sez. L'Aquila -- http://www.amyresource.it/AGI/

 [11/11] from: deadzaphod:hot:mail at: 8-Aug-2000 20:55


The only way I know of to intercept the escape key is to set system/console/break to off/false, then use a console port (i.e. port: open [scheme: 'console]) to poll for input, the escape key generates two escape characters (to differentiate it from the arrow keys and such that produce a sequence beginning with escape). hope that helps, Cal

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted