Page 1 of 1 1
Topic Options
#130612 - 2004-12-06 03:04 AM how to accept the user choice
ozraelised Offline
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 Offline
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 Offline
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 Offline
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
#130616 - 2004-12-06 04:08 AM Re: how to accept the user choice
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
How about reading the manual.

You have to have fat fingered something cuz shawn's code works.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#130617 - 2004-12-06 04:25 AM Re: how to accept the user choice
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Remove the semi-colon from Shawn's code for it to really log you off.
Top
#130618 - 2004-12-06 04:39 AM Re: how to accept the user choice
ozraelised Offline
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
#130619 - 2004-12-06 04:41 AM Re: how to accept the user choice
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Thats because you forgot some code, you forgot the $Answer = part, like this:

$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)

-Shawn

Top
#130620 - 2004-12-06 04:44 AM Re: how to accept the user choice
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Quote:

I looked in the manual but still can't see where I can find the vlues for the user choice



You need to get a bigger font! DOC even posted the relevant portion in this thread.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#130621 - 2004-12-06 05:03 AM Re: how to accept the user choice
ozraelised Offline
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
#130622 - 2004-12-06 05:07 AM Re: how to accept the user choice
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
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.

etc.... as in the manual and posted above.

Do you really want to SHUTDOWN the computer or just log them off? You should also silence your commands so they don't show the 1 and 0 from running commands.

Shutdown is only on XP/2003 if you have 2000 Workstations then by default they won't have that command.


You also should not need any external app to map a drive.

Top
#130623 - 2004-12-06 05:19 AM Re: how to accept the user choice
ozraelised Offline
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 Offline
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 Offline
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
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 884 anonymous users online.
Newest Members
fgarcia, Viginette, ManuvdWielNL, Sir_Barrington, batdk82
17889 Registered Users

Generated in 0.064 seconds in which 0.024 seconds were spent on a total of 12 queries. Zlib compression enabled.

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