Page 1 of 1 1
Topic Options
#182315 - 2007-11-07 01:19 PM For Sir_roYa - exit script when escape is pressed.
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
 Originally Posted By: Sir_roYa
how it works? The code must only continious when enter is pressed and exit when escape is pressed. sorry for my bad English:$


Try this:


Break ON
$sExit=Chr(27)
$sContinue=Chr(13)


While $sKeyPressed<>$sContinue
"Hit ENTER to continue or ESCAPE to exit: " Get $sKeyPressed
CHR(13)+" "+CHR(13)
Select
Case $sKeyPressed=$sContinue
; No action required
Case $sKeyPressed=$sExit
"You have requested an exit."+@CRLF
Exit 0
Case "Unknown Key"
"You have pressed an invalid key!"+@CRLF
EndSelect
Loop


"You have elected to continue..."+@CRLF



Top
#182319 - 2007-11-07 02:40 PM Re: For Sir_roYa - exit script when escape is pressed. [Re: Richard H.]
Sir_roYa Offline
Fresh Scripter

Registered: 2007-11-01
Posts: 13
Loc: Netherlands
Whoot specialy for me? Many thanks. And this is what I mean
But I thougt it was much easier but thanks:D I can use this
_________________________
Liefde zit in een klein hoekje,
Jammer dat de aarde rond is

Top
#182350 - 2007-11-08 01:58 PM Re: For Sir_roYa - exit script when escape is pressed. [Re: Sir_roYa]
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Another solution would be to launch a parent script like the one above that loops. The script could then launch additional processes which it would have to monitor. When Esc is pressed the parent script would need to kill the children or set a flag file which the child process would pick up and terminate.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#182382 - 2007-11-09 09:45 AM Re: For Sir_roYa - exit script when escape is pressed. [Re: Howard Bullock]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
All the guy needed was to exit the script if someone hit ESCAPE at a prompt. At least that's how I read the request.

Adding spawned child processes probably over-complicating it a teeny bit H. ;\)

Top
#182481 - 2007-11-12 10:54 AM Re: For Sir_roYa - exit script when escape is pressed. [Re: Richard H.]
Sir_roYa Offline
Fresh Scripter

Registered: 2007-11-01
Posts: 13
Loc: Netherlands
\:\) Yes Richard that's what I need. And the script works fine. Thanks for it
_________________________
Liefde zit in een klein hoekje,
Jammer dat de aarde rond is

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 1452 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.062 seconds in which 0.033 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org