MsgBox: Difference between revisions

From BR Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(10 intermediate revisions by 2 users not shown)
Line 1: Line 1:
MSGBOX (<PROMPT$>[, <TITLE$>][, <BUTTONS$>][, <ICON$>])
The '''MsgBox''' [[Internal Function]] will display a Windows Message Box. It has four possible parameters:  
The '''MsgBox''' [[Internal Function]] will display a Windows Message Box. It has four possible parameters:  
*PROMPT$
*PROMPT$
Line 9: Line 11:
'''TITLE$''' is a string containing the title of the message box.  
'''TITLE$''' is a string containing the title of the message box.  


'''BUTTONS$''' indicates which buttons will be displayed in the message box. If you don't specify a button configuration the OK button is displayed.The value of the button the user selects is returned to BR in CNT (see below).
'''BUTTONS$''' indicates which buttons will be displayed in the message box. If you don't specify a button configuration the OK button is displayed.The value of the button the user selects is returned to BR in CNT.


'''ICON$''' indicates what ICON, if any, will be displayed. If you don't specify a title, a blank title bar is displayed.  
The BUTTON$ value that is capitalized will become the default button (selected by the Enter key). For example, if "Yn" or "Ync" is specified then the Yes button becomes the default button. If "yN" or "yNc" is specified then the No button is displayed as the default button. The case of the "c" has no bearing on default button focus. If both or neither are capitalized, ie: "YN" or "yn", then the default is that YES is pre-selected.
 
====Examples====
 
00010 Let MSGBOX( PROMPT$, TITLE$, BUTTONS$, ICON$)
00020 Let VALUE= MSGBOX( "Record not Found", "Error", "OK", "ERR")
00030 Let MSGBOX( "End of Data", "NOTE")


====Acceptable values for BUTTONS$====
====Acceptable values for BUTTONS$====
Line 33: Line 29:
|}
|}


'''ICON$''' indicates what ICON, if any, will be displayed. If you don't specify a title, a blank title bar is displayed. All ICON$ values are case insensitive.


====Acceptable values for ICON$====
====Acceptable values for ICON$====
{|
{|
|-
|-
||'''INF'''||Displays (i) Information icon
||'''INF'''||Displays (i) Information icon
|-
|-
||'''ERR'''||Displays Error Icon (e.g. stop sign)
||'''ERR'''||Displays Error Icon, which is a stop or a red x sign (depends upon OS)
|-
|-
||'''EXCL'''||Displays Exclamation Point
||'''EXCL'''||Displays Exclamation Point
Line 48: Line 45:
|}
|}


===Examples===
00010 Let MSGBOX( PROMPT$, TITLE$, BUTTONS$, ICON$)
00020 Let VALUE= MSGBOX( "Record not Found", "Error", "OK", "ERR")
00030 Let MSGBOX( "End of Data", "NOTE")


All Buttons$ and Icon$ values are case insensitive except that if "Yn" or "Ync" is specified then the Yes button becomes the default button and if "yN" or "yNc" is specified then the No button is displayed as the default button (will be selected by the Enter key). The case of the "c" has no bearing on default button focus, and "YN" or "yn" are ambiguous with respect to default button focus.
 
;Complete Example:
00060  MsgBox('Are the labels aligned correctly?', 'check Printer', 'Yn', 'Qst')><2 then goto ALIGN
 
The example above will produce a message box like the image below.
"Yes" is the default button and will have an added border identifying it as such when running the program.
 
[[image:messagebox.jpg]]


====Returned Values====
====Returned Values====
Line 56: Line 64:
{|
{|
|-
|-
||'''0'''||An error occurred such as not enough memory. (quite rare)
||'''0'''||An error occurred such as not enough memory. (This is quite rare.)
|-
|-
||'''1'''||The OK button was selected.
||'''1'''||The OK button was selected.
Line 68: Line 76:
|}
|}


To force a new line in the text of a message box insert a CHR$(13) or HEX$("0D0A"), carriage return,in the text at the point where the word wrap should occur. If no line is forced Windows will determine a wrap point based on the width of the monitor.
In our example, if YES is not selected, it will return to the program and go to the line label ALIGN, which turns out to be another message box about aligning paper in the printer. If YES is selected, it simply continues with the program to print the labels:
00060  MSGBOX(PROMPT$, TITLE$, BUTTONS$, ICON$)><2 then goto ALIGN
 
====Line breaks in a message box====
To force a new line in the text of a message box insert a CHR$(13) or HEX$("0D0A"), carriage return, in the text at the point where the word wrap should occur. If no line is forced Windows will determine a wrap point based on the width of the monitor.
 
For example (and demonstrating the EXCL icon):
 
00100 let prompt$="Did you already run the ENDOFMONTH program?"&hex$("0D0A")&"If you did not, and continue anyways, records may be lost."&hex$("0D0A")&hex$("0D0A")&"Well - DID YOU?"
 
[[image:messagebox2.jpg]]
 
Two &hex$("0D0A") in a row will display a completely skipped line.


<noinclude>
<noinclude>
[[Category: Internal Functions]]
[[Category: Internal Functions]]
</noinclude>
</noinclude>

Latest revision as of 13:14, 6 October 2015

MSGBOX (<PROMPT$>[, <TITLE$>][, <BUTTONS$>][, <ICON$>])

The MsgBox Internal Function will display a Windows Message Box. It has four possible parameters:

  • PROMPT$
  • TITLE$
  • BUTTONS$
  • ICON$

PROMPT$ is the only required parameter. It is a string which is to be displayed within the message box.

TITLE$ is a string containing the title of the message box.

BUTTONS$ indicates which buttons will be displayed in the message box. If you don't specify a button configuration the OK button is displayed.The value of the button the user selects is returned to BR in CNT.

The BUTTON$ value that is capitalized will become the default button (selected by the Enter key). For example, if "Yn" or "Ync" is specified then the Yes button becomes the default button. If "yN" or "yNc" is specified then the No button is displayed as the default button. The case of the "c" has no bearing on default button focus. If both or neither are capitalized, ie: "YN" or "yn", then the default is that YES is pre-selected.

Acceptable values for BUTTONS$

OK Displays OK button (default)
YN Displays Yes and No buttons
OKC Displays OK and Cancel buttons
YNC Displays Yes, No and Cancel buttons


ICON$ indicates what ICON, if any, will be displayed. If you don't specify a title, a blank title bar is displayed. All ICON$ values are case insensitive.

Acceptable values for ICON$

INF Displays (i) Information icon
ERR Displays Error Icon, which is a stop or a red x sign (depends upon OS)
EXCL Displays Exclamation Point
QST Displays a Question Mark

Examples

00010 Let MSGBOX( PROMPT$, TITLE$, BUTTONS$, ICON$)
00020 Let VALUE= MSGBOX( "Record not Found", "Error", "OK", "ERR")
00030 Let MSGBOX( "End of Data", "NOTE")


Complete Example
00060   MsgBox('Are the labels aligned correctly?', 'check Printer', 'Yn', 'Qst')><2 then goto ALIGN

The example above will produce a message box like the image below. "Yes" is the default button and will have an added border identifying it as such when running the program.

Returned Values

Possible return values are:

0 An error occurred such as not enough memory. (This is quite rare.)
1 The OK button was selected.
2 The YES button was selected.
3 The NO button was selected.
4 The CANCEL button was selected, or ESC was pressed. (The ESC key has no affect when the Cancel button is not displayed.)

In our example, if YES is not selected, it will return to the program and go to the line label ALIGN, which turns out to be another message box about aligning paper in the printer. If YES is selected, it simply continues with the program to print the labels:

00060   MSGBOX(PROMPT$, TITLE$, BUTTONS$, ICON$)><2 then goto ALIGN

Line breaks in a message box

To force a new line in the text of a message box insert a CHR$(13) or HEX$("0D0A"), carriage return, in the text at the point where the word wrap should occur. If no line is forced Windows will determine a wrap point based on the width of the monitor.

For example (and demonstrating the EXCL icon):

00100 let prompt$="Did you already run the ENDOFMONTH program?"&hex$("0D0A")&"If you did not, and continue anyways, records may be lost."&hex$("0D0A")&hex$("0D0A")&"Well - DID YOU?"

Two &hex$("0D0A") in a row will display a completely skipped line.