Display Functions
Contents
cla140
Contents
Display functions are not supported on Linux platforms.
ClearScreen or ClrScr - Clear the Screen
Valid on Windows platforms
The ClearScreen or ClrScr function clears the screen.
Function format:
ClearScreen() as Boolean
The display function always returns TRUE.
Example:
This example prints five lines, waits 5 seconds, and then clears the screen.
Dim counter as integer 'Print 5 lines For counter = 1 to 5 Print("Line " + str(counter)) Next 'Wait 5 seconds Sleep(5000) 'Clear the print screen ClearScreen() Print("Screen Cleared")
InputBox - Create, Display, and Operate a Message Box Window
Valid on Windows and Windows CE
The InputBox function creates, displays, and operates a message box window. The message box contains an application-defined prompt, title, and a text box with an application-defined default value, and the OK and Cancel buttons.
This miscellaneous function has the format:
InputBox( prompt as String, title as String, default as String) as Boolean
- promptThis parameter indicates the prompt to be displayed.
- titleThis parameter specifies the message box title.
- defaultThis parameter specifies the default prompt input. If default is not a variable, a syntax error exists.
The input box is NOT placed in the foreground.
If the OK button was selected, the function returns TRUE. The function also copies the contents of the text box into the default variable. If the Cancel button was selected, the function returns FALSE. The function also leaves the default variable unchanged.
Example:
This example demonstrates the use of InputBox.
Dim TargetPath, Question as string TargetPath=WindowsDir Question="Please specify the directory to use for installation" if InputBox(Question,"Install",TargetPath) then ' Place code for actual installation here... MessageBox("Installation completed") else MessageBox("Installation aborted") End if End:
MessageBox or MsgBox - Display a Message Box Window
Valid on Windows and Windows CE
The MessageBox or MsgBox function displays a message box window. The message box contains a message, a title, and any combination of the predefined buttons that the style parameter describes.
Instead of MessageBox, you can use MsgBox to call the function.
Function format:
MessageBox(message as String, title as String, style as Integer) as Integer MessageBox(message as String, title as String) as Integer MessageBox(message as String, style as Integer) as Integer MessageBox(message as String) as Integer
- messageThis parameter identifies the string containing the message that is displayed.
- titleThis parameter identifies an optional string containing the message box title.Default:DMS
- styleThis parameter identifies an optional integer specifying the contents and behavior of the message box. The style parameter can be any of the following predefined constants:
- MB_OKThis constant adds box with button OK (Default)
- MB_OKCANCELThis constant adds box with buttons OK and Cancel
- MB_YESNOThis constant adds box with buttons Yes and No
- MB_RETRYCANCELThis constant adds box with buttons Retry and Cancel
- MB_YESNOCANCELThis constant adds box with buttons Yes, No, and Cancel
- MB_ABORTRETRYIGNOREThis constant adds box with buttons Abort, Retry, and Ignore
Constants for MessageBox Modality
By default, the user must respond to the message box before continuing work in the current window. However, the user can move to, and work in, windows of other applications.
- MB_SYSTEMMODALAll applications are suspended until the user responds to the message box. System modal message boxes are used to notify the user of serious, potentially damaging errors that require immediate attention.
Constants for MessageBox Icons
The default is as follows: No icon is shown.
- MB_ICONEXCLAMATIONThis constant adds an exclamation point icon appears in the message box.
- MB_ICONINFORMATIONThis constant adds an icon consisting of an "i" in a circle appears in the message box.
- MB_ICONQUESTIONThis constant adds a question-mark icon in the message box.
- MB_ICONSTOPThis constant adds a stop sign icon (white "X" in a red circle) appears in the message box.
Constants for MessageBox Default Buttons
The default is as follows. The first button is the default.
- MB_DEFBUTTON2This constant makes the second button default.
- MB_DEFBUTTON3This constant makes the third button default.
Other Constants
- MB_SETFOREGROUNDThis constant sets the message box as the foreground window. If this constant is not coded, the current foreground window remains in the foreground.
You can combine each constant of one group with any constant of another group. For example, to display a message box with Abort, Retry, and Ignore (default) buttons, and a stop sign icon, and you want to suspend all applications until the user responds, code using the following style:
MB_ABORTRETRYIGNORE + MB_DEFBUTTON3 + MB_ICONSTOP + MB_SYSTEMMODAL
If the style parameter is omitted, MB_OK is assumed and the message box contains only the OK button.
If there is not enough memory to create the message box, the return value of the function is zero. Otherwise, it is one of the following button values that the message box returns:
- IDOKValue 1; the OK button was clicked.
- IDCANCELValue 2; the Cancel button (or keyboard Esc key) was clicked.
- IDABORTValue 3; the Abort button was clicked.
- IDRETRYValue 4; the Retry button was clicked.
- IDIGNOREValue 5; the Ignore button was clicked.
- IDYESValue 6; the Yes button was clicked.
- IDNOValue 7; the No button was clicked.
Example:
This example checks with the user for creating a backup copy of the config.sys file. The backup is created, if necessary.
Dim Src,Dst as string Dim Question as string Question="Do you want to make a backup of your config.sys?" if MessageBox(Question,MB_YESNO)=IDYES then Src="C:\CONFIG.SYS" Dst="C:\CONFIG.BAK" if CopyFile(Src,Dst,TRUE) then MessageBox("CONFIG.BAK created.") end if
ProgressBar - Set the Progress Bar
Valid on Windows platforms
The ProgressBar function sets the progress bar on the main window to the percentage indicated.
Display function format:
ProgressBar(percentage as Integer) as Boolean
- percentageThis parameter indicates the value of progress (percent).
On successful completion, the function returns TRUE; otherwise, it returns FALSE.
Example:
This example shows the ProgressBar and ProgressText functions.
Dim counter as Integer For counter = 1 TO 10 ProgressBar(counter * 10) ProgressText("Now processing : " + Str(counter) ) Sleep(500) 'Wait half second Next
ProgressText - Copy a String to the Progress Text Field
Valid on Windows only
The ProgressText function copies the string to the progress text field in the Main window.
Display function format:
ProgressText(text as String) as Boolean
- textThis parameter defines text for the progress text field.
On successful completion, the function returns TRUE, otherwise it returns FALSE.
Example:
This example shows the ProgressBar and ProgressText functions.
Dim counter as Integer For counter = 1 TO 10 ProgressBar(counter * 10) ProgressText("Now processing : " + Str(counter) ) Sleep(500) 'Wait half second Next