The following script is behaving in a way I don't understand. If you start the script then press the "Ok" button, you will no longer be able to close the dialog and thus stop the script unless you're running it from the editor, in which case the dialog closes and the script stops as I would expect.
Another odd thing is that at first I mistakenly left out the VBSTART/VBEND block and yet the VBEVAL timer line seemed to work. At least the script timed out. Help for VBStart still says:
Any thoughts? What am I missing?If you wish to evaluate VBScript expressions in your scripts you will need a VBSTART/VBEND block at the start of your script even if it contains no code.
Thanks,
Dick
Code: Select all
VBSTART
VBEND
//variable for the timeout period
Let>Waiting=5
Dialog>Dialog1
object Dialog1: TForm
Left = 329
Top = 205
HelpContext = 5000
BorderIcons = [biSystemMenu]
Caption = 'Do Something'
ClientHeight = 140
ClientWidth = 325
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = True
ShowHint = True
OnTaskBar = False
PixelsPerInch = 96
TextHeight = 13
object Label1: TLabel
Left = 40
Top = 16
Width = 258
Height = 24
Caption = 'We are about to do something.'
ParentFont = False
end
object Label2: TLabel
Left = 40
Top = 48
Width = 140
Height = 24
Caption = 'Please pick Ok...'
ParentFont = False
end
object MSButton1: tMSButton
Left = 128
Top = 98
Width = 75
Height = 25
Caption = 'Ok'
DoubleBuffered = True
ParentDoubleBuffered = False
TabOrder = 0
DoBrowse = False
BrowseStyle = fbOpen
end
end
EndDialog>Dialog1
//Dialog handler to exit the script when the dialog closes
AddDialogHandler>Dialog1,,OnClose,Quit
//Dialog handler to start "Process" subroutine when the Ok button is pressed
AddDialogHandler>Dialog1,msButton1,OnClick,Process
Show>dialog1,res1
SRT>Quit
Exit>0
END>Quit
SRT>Process
//Change the dialog text and remove the Ok button
SetDialogProperty>Dialog1,Label1,Caption,Waiting for Something.
SetDialogProperty>Dialog1,Label2,Caption,Please be patient...
SetDialogProperty>Dialog1,,Caption,Waiting...
SetDialogObjectVisible>Dialog1,msButton1,0
SetFocus>Waiting...
//Timer start
VBEval>Timer,StartTime
//Loop until "TotalTime" surpasses "Waiting"
Label>WaitLoop
Wait>0.01
VBEval>Timer-%StartTime%,TotalTime
If>TotalTime>Waiting
SetDialogProperty>Dialog1,Label1,Caption, Thanks for waiting
SetDialogProperty>Dialog1,Label2,Caption, Goodbye...
Wait>2
Exit>0
EndIF
Goto>WaitLoop
END>Process