#130612 - 2004-12-06 03:04 AM
how to accept the user choice
|
ozraelised
Getting the hang of it
Registered: 2002-12-02
Posts: 59
Loc: Albury
|
Hi,
This is my script:
$ = Setoption("wrapateol","on") Color w+/n MessageBox ("<text>", "Remider",4180)
how can I add the If optin to the end of the script, so if the user press the no he will logout or if yes he will login.
Thanks
|
|
Top
|
|
|
|
#130613 - 2004-12-06 03:28 AM
Re: how to accept the user choice
|
Shawn
Administrator
   
Registered: 1999-08-13
Posts: 8611
|
Something like this should do the trick:
Code:
$Answer = MessageBox ("<text>", "Remider",4180)
If $Answer <> 6
?"Log yo ass off ..."
; Logoff(1)
Endif
-Shawn
|
|
Top
|
|
|
|
#130614 - 2004-12-06 04:01 AM
Re: how to accept the user choice
|
NTDOC
Administrator
   
Registered: 2000-07-28
Posts: 11634
Loc: Space
|
Please review the manual that comes with the distribution of KiXtart.
Quote:
MessageBox( )
Action: Displays a standard dialog box in Windows. Syntax: MESSAGEBOX ("message", "title", style, time-out) Parameters: Message The message to display in the dialog box.
Title
The title of the dialog box.
Style (optional)
Optional numeric expression that is the sum of values specifying the number and type of buttons to display, the icon style to use, the identity of the default button, and the modality. The following table illustrates the values used and the meaning of each group of values.
Buttons to display
Value Meaning 0 Display OK button only. 1 Display OK and Cancel buttons. 2 Display Abort, Retry, and Ignore buttons. 3 Display Yes, No, and Cancel buttons. 4 Display Yes and No buttons. 5 Display Retry and Cancel buttons.
Icon to display
Value Meaning 16 Stop symbol 32 Question mark 48 Exclamation mark 64 Information symbol
Default button
Value Meaning 0 First button is default. 256 Second button is default. 512 Third button is default.
Modality
Value Meaning 0 Application-modal. The user must respond to the message box before continuing work in the application. 4096 System-modal. All applications are suspended until the user responds to the message box.
When adding numbers to create a final value for the argument type, use only one number from each group. If style is omitted, a default value of 0 is assumed.
Time-out (optional)
Optional numeric expression representing the number of seconds after which to close the dialog box.
Note: The time-out feature only works if the MESSAGEBOX dialog box is the active window for the duration of the time-out. If the user switches away from KiXtart and activates another application, the MESSAGEBOX dialog box is not closed. Remarks: MESSAGEBOX displays a maximum of 1024 characters in application-modal dialog boxes. Longer messages are truncated after the 1024th character. Message strings longer than 255 characters with no intervening spaces are truncated after the 255th character. For system-modal dialog boxes, the number of characters you can display depends on screen resolution and number of lines in the message. MESSAGEBOX breaks lines automatically at the right edge of the dialog box. If you want to set line breaks yourself, place a linefeed (ANSI character 10) before the first character of the text that is to begin each new line. Returns: The value returned by MESSAGEBOX indicates which button was selected, as shown in the following table. Value Meaning -1 User did not respond to the dialog box within the specified time-out period. 1 OK button selected. 2 Cancel button selected. 3 Abort button selected. 4 Retry button selected. 5 Ignore button selected. 6 Yes button selected. 7 No button selected.
If the dialog box contains a Cancel button, pressing esc has the same effect as choosing Cancel. Example: $Selection = MessageBox("Do you want to continue ?", "KiXtart", 36) If $Selection = 6 ? "Yes selected, continuing...." Endif
--------------------------------------------------------------------------------
|
|
Top
|
|
|
|
#130615 - 2004-12-06 04:05 AM
Re: how to accept the user choice
|
ozraelised
Getting the hang of it
Registered: 2002-12-02
Posts: 59
Loc: Albury
|
I tried your suggestion and no matter what the user choice was I get the message "logg yo ass off"
I think I made a mistake by explainng what I needed. If the user click the No button on the meesagebox I want the user to logoff automaticlly with out any choice on the user side.
why did you use the value 6? where can I find more information on that
thanks
|
|
Top
|
|
|
|
#130618 - 2004-12-06 04:39 AM
Re: how to accept the user choice
|
ozraelised
Getting the hang of it
Registered: 2002-12-02
Posts: 59
Loc: Albury
|
Thank for that, I looked in the manual but still can't see where I can find the vlues for the user choice. Any way I know now( your reply) I will look and see is I can find it in the manual.
I change the script to the following, it all works until I choose a yes or no on the message box:
$ = Setoption("wrapateol","on") Color r+/n MessageBox ("please confirm that you have read and understood the firm's IT policy. If you have any questions relative to this please contact Gary or Rae", "Remider",4180) If $Answer <> 6 MessageBox ( "You are unable to log to the network ") Shutdown ("","Please contact Gary or Rae",10,,1,2) Else MessageBox ("You are now being connected to the network","Welcome to Johnsons MME",,5) connDrvs.scr ; this to map the netwrok drive
Endif
|
|
Top
|
|
|
|
#130621 - 2004-12-06 05:03 AM
Re: how to accept the user choice
|
ozraelised
Getting the hang of it
Registered: 2002-12-02
Posts: 59
Loc: Albury
|
Thanks, is that correct?
$ = Setoption("wrapateol","on") Color r+/n ;Display "\\JMMES\netlogon\netusage.txt" ; display file contents on screen MessageBox ("please confirm that you have read and understood the firm's IT policy. If you have any questions relative to this please contact Gary or Rae", "Remider",4180) $Answer = MessageBox ("please confirm that you have read and understood the firm's IT policy. If you have any questions relative to this please contact Gary or Rae", "Remider",4180) If $Answer <> 6 MessageBox ( "You are unable to log to the network ") Shutdown ("","Please contact Gary or Rae",10,,1,2) Else MessageBox ("You are now beeing connected to the network","Welcome to Johnsons MME",,5) connDrvs.scr ; this script will map the netwrok drive
Endif
|
|
Top
|
|
|
|
#130623 - 2004-12-06 05:19 AM
Re: how to accept the user choice
|
ozraelised
Getting the hang of it
Registered: 2002-12-02
Posts: 59
Loc: Albury
|
NTDOC,
Logging them off will be a better option since I have windows 2000 in the office. What do you mean by "silence your commands .....? As to the external app to map a drive you are right I am going to copy the code to this script.
Again to all of you thank you for your help
|
|
Top
|
|
|
|
#130624 - 2004-12-06 06:44 AM
Re: how to accept the user choice
|
ozraelised
Getting the hang of it
Registered: 2002-12-02
Posts: 59
Loc: Albury
|
Ok, so it takes me a bit of time to get it right.
If you can provide me with some information on how to log off the user and run the script in silence that will be great help.
Thanks
|
|
Top
|
|
|
|
#130625 - 2004-12-06 06:57 AM
Re: how to accept the user choice
|
NTDOC
Administrator
   
Registered: 2000-07-28
Posts: 11634
Loc: Space
|
Silencing means to prevent the result code from displaying on the console.
Here is an FAQ (Frequently Asked Question) on the subject Why does the console display zeros and ones (amongst others)? http://www.kixtart.org/ubbthreads/showflat.php?Cat=&Number=81592 As for your code, here it is cleaned up a little.
Code:
Dim $SO $SO=SetOption('Explicit','On') $SO=SetOption('NoVarsInStrings','On') $SO=SetOption('WrapAtEOL','On') Dim $Msg, $Answer Color r+/n Display '\\JMMES\netlogon\netusage.txt' ; display file contents on screen $Answer=MessageBox ("Please confirm that you have read and understood the firm's IT policy. If you have any questions relative to this please contact Gary or Rae", "Reminder",4164) If $Answer <> 6 $Msg=MessageBox ( "You are unable to log to the network, Please contact Gary or Rae if you have further questions ") Logoff(1) Else $Msg=MessageBox ("You are now being connected to the network","Welcome to Johnsons MME",64,5) USE S: "\\JMMES\Someshare" Endif
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 884 anonymous users online.
|
|
|