INFOBOX Instruction |
INFOBOX(ACTION=DEFINE, options) "messagestring"
INFOBOX(ACTION=MODIFY, options) "messagestring"
INFOBOX(ACTION=REMOVE)
INFOBOX displays a dialog box which remains on the screen until it is removed with a subsequent INFOBOX(ACTION=REMOVE) instruction. It is primarily used to display status or progress information to the user during long operations, such as Monte Carlo simulations.
You can display a graphical "progress bar" and one or two lines of text in the dialog box. The ACTION=MODIFY allows you to update the status of the progress bar and change the second line of text in the box. If you are showing a progress bar and the process takes a sufficiently long time, an estimated time to completion will also be shown.
Parameters
"messagestring" |
(Optional) Message to display in the dialog box. When used with the ACTION=DEFINE option, this sets the first line of text. The first line cannot be changed later. Use it to describe the overall operation. With ACTION=MODIFY, messagestring sets the second line of text, which you can change each time you use ACTION=MODIFY. You can supply this as a string of text enclosed in quotes, or as a LABEL or STRING type variable. |
Options
ACTION=DEFINE/[MODIFY]/REMOVE
ACTION=DEFINE creates and displays the information box. If you want to display a progress bar in the dialog, you must include the PROGRESS, LOWER, and UPPER options when you do ACTION=DEFINE. The messagestring parameter, if supplied, is displayed as the first line in the dialog box.
ACTION=MODIFY updates the box. Use this along with the CURRENT option to update the progress bar, or with the messagestring parameter to replace the second line of text in the dialog box.
The ACTION=REMOVE option removes the box from the screen.
PROGRESS/[NOPROGRESS]
Used with ACTION=DEFINE, determines whether the box will include a progress bar. You must specify values for LOWER and UPPER when you use PROGRESS. Once the operation has taken longer than ten seconds, an estimate of the time to completion is added to the box. This assumes that the time required from lower bound to upper bound is roughly linear.
LOWER=integer lower bound value [1]
UPPER=integer upper bound value
Use these, with ACTION=DEFINE and PROGRESS, to set the lower and upper bounds for the progress of your operation. LOWER and UPPER are integer-valued.
CURRENT=current value
Use this (with ACTION=MODIFY) to indicate how much of the distance from LOWER to UPPER has been completed. For example, if you set LOWER=1 and UPPER=100, INFOBOX(ACTION=MODIFY,CURRENT=50) would display the bar as 50% completed.
Examples
infobox(action=define,progress,lower=-nburn,upper=ndraws) "Gibbs sampling"
do draw=-nburn,ndraws
DO DRAW PROCEDURE
infobox(current=draw)
if draw<=0
next
DO BOOKKEEPING
end do draws
infobox(action=remove)
This is the usual set up for Gibbs sampling. NBURN is the number of "burn-in" draws, NDRAWS is the number of draws that you want to save. The "DO DRAW PROCEDURE" and "DO BOOKKEEPING" need to be replaced with whatever is appropriate for a particular application.
The messagestring can be created to show information which might be helpful in deciding to stop the calculations. The code below will display a running estimate of the acceptance rate of a Metropolis-Hastings Markov Chain. If the rate is lower than you would like, you can cancel the process and adjust the way the draws are done.
compute accept=0
infobox(action=define,progress,lower=1,upper=ndraws) "Metropolis"
do draw=1,ndraws
...
if alpha>1.0.or.%uniform(0.0,1.0)<alpha {
compute accept=accept+1
}
infobox(current=draw) $
"Acceptance Rate "+%strval(100.0*accept/draw,"###.##")
end do draw
infobox(action=remove)
Copyright © 2025 Thomas A. Doan