Page 1 of 1 1
Topic Options
#31243 - 2002-10-23 03:19 PM Stop script.
Koen van der Aa Offline
Fresh Scripter

Registered: 2002-07-13
Posts: 7
Hi there,

I want the users to decide if the logon script should run or not. How can I do that?

It should work like this:

Question: Continue with login script Y/N:
If N selected then script should close.

Grtz.

Top
#31244 - 2002-10-23 03:23 PM Re: Stop script.
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Generally speaking if you architect your script and file placement correctly, answering your question will probably take as long letting the script execute.

But look at the manual for the "?", "GET", "IF", and "EXIT" commands. You can use them to do want.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#31245 - 2002-10-23 03:27 PM Re: Stop script.
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
How about something like this:

code:
Break On

Do
?"Continue with login script Y/N: " Gets $Answer
Until $Answer = "Y" Or $Answer = "N"

If $Answer = "N"
Quit()
Else
?"Carry on..."
Endif

Exit 1

-Shawn

[ 23. October 2002, 15:28: Message edited by: Shawn ]

Top
#31246 - 2002-10-23 03:35 PM Re: Stop script.
Waltz Offline
Seasoned Scripter

Registered: 2002-08-01
Posts: 485
Loc: Waterloo, Ontario, Canada
...or Shawn's UDF Choice (), [which he apparently forgot that he wrote... [Big Grin] ]
code:
Function Choice($prompt,optional $choices)
dim $i,$c,$opts,$key
if not $choices
$choices = "YN"
endif
for $i = 1 to len($choices)
$opts = $opts + substr($choices,$i,1) + ","
next
$prompt = $prompt+" ["+substr($opts,1,len($opts)-1) + "] ? "
? $prompt
while 1
get $c
if asc($c) = 3 ; ^c
$choice = ""
exit 0
endif
$key = instr($choices,$c)
if $key
$c = ucase($c)
$c ; echo
$choice = $c
exit $key
else
beep
endif
loop
EndFunction

_________________________
We all live in a Yellow Subroutine...

Top
#31247 - 2002-10-23 03:37 PM Re: Stop script.
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
The user should have no choice whether the login script run or not. If you want to provide some kind of optional script to do stuff, then you can put a shortcut/link onto the user's desktop and they can click on it if they want to run it.

Giving a user choices will confuse them. They will always select the wrong choice and then blame you.
_________________________
There are two types of vessels, submarines and targets.

Top
#31248 - 2002-10-23 03:38 PM Re: Stop script.
Koen van der Aa Offline
Fresh Scripter

Registered: 2002-07-13
Posts: 7
Thanx Shawn, it works.
Top
#31249 - 2002-10-23 03:53 PM Re: Stop script.
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Choice() - forgot all about that :0

Koen:

Might want to take Howards suggestion and use the GET command instead of the GETS command [just swap GET for GETS]

Interesting benefits to this are as follows:

1) User doesn't have to press ENTER after hitting the Y/N keys.

2) User can't break out of loop with ctrl-c, which may be a good thing or a bad thing - depending on your requirements.

-Shawn

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 369 anonymous users online.
Newest Members
rrosell, PatrickPinto, Raoul, Timothy, Jojo67
17877 Registered Users

Generated in 0.064 seconds in which 0.026 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