Core Function MsgBox

From Sputnik Wiki
(Difference between revisions)
Jump to: navigation, search
(Created page with "<pre> MsgBox( <expression> ) </pre> === Description === Show a message dialog. === Usage === With a string: <syntaxhighlight lang="sputnik"> MsgBox("Hello."); </syntaxhighli...")
 
m (3 revisions)
 
(13 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
<pre>
 
<pre>
MsgBox( <expression> )
+
MsgBox( <message>, <title>, <flag>, <timeout> )
 
</pre>
 
</pre>
  
 
=== Description ===
 
=== Description ===
  
Show a message dialog.
+
Displays a message to the user.
  
=== Usage ===
+
=== Parameters ===
  
With a string:
+
==== message ====
  
<syntaxhighlight lang="sputnik">
+
The text of the message box.
MsgBox("Hello.");
+
</syntaxhighlight>
+
  
With a variable:
+
==== title ====
 +
 
 +
The title of the message box.
 +
 
 +
The default title is "MessageBox".
 +
 
 +
==== flag ====
 +
 
 +
Optional; The flag indicates the type of message box and the possible button combinations. See remarks.
 +
 
 +
Default 64 (Information).
 +
 
 +
==== timeout ====
 +
 
 +
Optional; Timeout in seconds. After the timeout has elapsed the message box will be automatically closed.
 +
 
 +
=== Return Value ===
 +
 
 +
Success: Returns the ID of the button pressed.
 +
 
 +
Failure: Returns -1 if the message box timed out.
 +
 
 +
<pre>
 +
Button Pressed Return Value 
 +
OK 1
 +
CANCEL 2
 +
ABORT 3
 +
RETRY 4
 +
IGNORE 5
 +
YES 6
 +
NO 7
 +
TRY AGAIN 10
 +
CONTINUE 11
 +
</pre>
 +
 
 +
=== Remarks ===
 +
 
 +
MsgBox does support Unicode by the way.
 +
 
 +
The flag parameter can be a combination of the following values:
 +
 
 +
<pre>
 +
decimal flag Button-related Result Hexadecimal flag
 +
0 OK button 0x0
 +
1 OK and Cancel 0x1
 +
2 Abort, Retry, and Ignore 0x2
 +
3 Yes, No, and Cancel 0x3
 +
4 Yes and No 0x4
 +
5 Retry and Cancel 0x5
 +
6 Cancel, Try Again, Continue 0x6
 +
 
 +
decimal flag Icon-related Result Hexadecimal flag
 +
0 (No icon) 0x0
 +
16 Stop-sign icon 0x10
 +
32 Question-mark icon 0x20
 +
48 Exclamation-point icon 0x30
 +
64 Icon consisting of an 'i' in a circle 0x40
 +
 
 +
decimal flag Default-related Result Hexadecimal flag
 +
0 First button is default button 0x0
 +
256 Second button is default button 0x100
 +
512 Third button is default button 0x200
 +
 
 +
decimal flag Modality-related Result Hexadecimal flag
 +
0 Application  0x0
 +
4096 System modal (dialog has an icon) 0x1000
 +
8192 Task modal 0x2000
 +
 
 +
decimal flag Miscellaneous-related Result Hexadecimal flag
 +
0 (nothing else special) 0x0
 +
262144 MsgBox has top-most attribute set 0x40000
 +
524288 title and text are right-justified 0x80000
 +
</pre>
 +
 
 +
=== Example ===
  
 
<syntaxhighlight lang="sputnik">
 
<syntaxhighlight lang="sputnik">
$testing = "Kittens";
+
MsgBox("My Message");
MsgBox($testing);
+
MsgBox("My Message", "My Title");
 +
MsgBox("My Message", "My Title", 32);
 +
MsgBox("My Message", "My Title", 32, 3);
 +
 
 +
// Example making a messagebox with question message and a yes no then get the result
 +
$Result = MsgBox("My Message", "My Title", 32 | 4); // Binary operator
 +
If ( $Result == 6 ) // Yes
 +
{
 +
MsgBox("You pressed yes");
 +
}
 +
Else If ( $Result == 7 ) // No
 +
{
 +
MsgBox("You pressed no");
 +
}
 +
else
 +
{
 +
MsgBox("Im not sure what you pressed....");
 +
}
 +
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==== Some Examples ====
+
[[Category:Core Function]]

Latest revision as of 12:38, 14 June 2015

MsgBox( <message>, <title>, <flag>, <timeout> )

Contents

Description

Displays a message to the user.

Parameters

message

The text of the message box.

title

The title of the message box.

The default title is "MessageBox".

flag

Optional; The flag indicates the type of message box and the possible button combinations. See remarks.

Default 64 (Information).

timeout

Optional; Timeout in seconds. After the timeout has elapsed the message box will be automatically closed.

Return Value

Success: Returns the ID of the button pressed.

Failure: Returns -1 if the message box timed out.

Button Pressed 		Return Value  
OK 			1 
CANCEL 			2 
ABORT 			3 
RETRY 			4 
IGNORE 			5 
YES 			6 
NO 			7 
TRY AGAIN 		10 
CONTINUE 		11 

Remarks

MsgBox does support Unicode by the way.

The flag parameter can be a combination of the following values:

decimal flag 	Button-related Result			Hexadecimal flag 
0		OK button 				0x0 
1 		OK and Cancel 				0x1 
2 		Abort, Retry, and Ignore 		0x2 
3 		Yes, No, and Cancel 			0x3 
4 		Yes and No 				0x4 
5 		Retry and Cancel 			0x5 
6 		Cancel, Try Again, Continue 		0x6 

decimal flag 	Icon-related Result 			Hexadecimal flag 
0 		(No icon) 				0x0 
16 		Stop-sign icon 				0x10 
32		Question-mark icon 			0x20 
48 		Exclamation-point icon 			0x30 
64		Icon consisting of an 'i' in a circle	0x40 

decimal flag 	Default-related Result 			Hexadecimal flag 
0 		First button is default button 		0x0 
256 		Second button is default button 	0x100 
512 		Third button is default button 		0x200 

decimal flag 	Modality-related Result 		Hexadecimal flag 
0		Application  				0x0 
4096 		System modal (dialog has an icon) 	0x1000 
8192 		Task modal 				0x2000 

decimal flag 	Miscellaneous-related Result 		Hexadecimal flag 
0 		(nothing else special) 			0x0 
262144 		MsgBox has top-most attribute set 	0x40000 
524288 		title and text are right-justified	0x80000 

Example

MsgBox("My Message");
MsgBox("My Message", "My Title");
MsgBox("My Message", "My Title", 32);
MsgBox("My Message", "My Title", 32, 3);
 
// Example making a messagebox with question message and a yes no then get the result
$Result = MsgBox("My Message", "My Title", 32 | 4); // Binary operator
If ( $Result == 6 ) // Yes
{
	MsgBox("You pressed yes");
}
Else If ( $Result == 7 ) // No
{
	MsgBox("You pressed no");
}
else
{
	MsgBox("Im not sure what you pressed....");
}
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox