Purpose |
This MapBasic script shows how to use only MB to make sure that a dialog stays
displayed for a given delay and that it can be closed only by the user clicking
the OK button.
|
Authors | Date of code (original) | Updated on | Date of page (original) | Updated on |
David Windeler
Jacques Paris |
17Aug2001
|
|
28Aug2001
|
|
Restrictions on use |
This example is distributed under the terms of the
Lesser GNU General Public License. Restrictions on the use of this
work in a commercial application or derivative work is described in
the Lesser GNU General Public License page at:
http://www.fsf.org/copyleft/lesser.html
|
Description |
The timer() function is used to
register the display time of the dialog, a handler is attached to the OK
button and a loop restores the dialog when the user clicks on the Cancel button
(if present) or on the x button at the upper right corner of the dialog.
The OK button handler checks the actual computer time against the registered starting time plus the delay, and closes the dialog when the right is right. |
External resources |
none
|
MapBasic Code. Copy/Paste if needed.
|
Parts
that are essential to the solution are in bold declare
sub main declare
sub hold declare
sub next ' just for
demo sake '
"dim" can be replaced by "global" '
delay is used to shows clearly how it is used; '
could be eliminated and replaced by a numeric value in the sub dim
startime, delay as integer sub
main delay=3
' sets the delay in seconds startime=timer() loop1: dialog
title
"Wait a minute,... or less"
control statictext title "Very important message. "
+ "Press ok to close it, but you may have to wait"
control okbutton calling hold if
not commandinfo(1) then goto loop1 end if '
program continues directly note
"Next operation..." '
or by calling a sub call
next end
sub sub
hold while
startime+delay>timer() dialog
preserve wend dialog
remove end
sub sub
next note
"next..." end
sub |
Availability for download |
Comments |
It is the closest we came to full automation with MB. The
dialog does not close by itself, the user must still intervene by clicking the
OK button.
If the user does not click the OK button, the dialog does not close even if the right time has been reached. |
See also |