Here's a workable copy of your script. I removed your image and other lines from the dialog for brevity. and added a "doCloseMainMenu" subroutine to make it self contained.
In my opinion you need to be using a non-modal dialog. Modal dialogs are designed to display permanently. Non-modal dialogs can be turned on and off at will.
I can't explain why Closedialog> works from a script when you have a modal dialog. In my opinion it should not. From a modal dialog, you can only process subroutines. When the subroutine completes, the script returns to the dialog. If the dialog is closed, the user has no way to continue and the script is left hanging.
If you need to use a modal dialog, then I suggest controlling its visibility by using SetDialogProperty>DialogName,,Visible,False and SetDialogProperty>DialogName,,Visible,True.
Code: Select all
Dialog>Login
object Login: TForm
BorderIcons = []
BorderStyle = bsSingle
Caption = 'Fichera Yard Maintenance - Login'
ClientHeight = 113
ClientWidth = 281
object Label1: TLabel
Left = 120
Top = 16
Width = 137
Height = 13
Caption = 'Please Enter Your Password:'
end
object LoginPass: TEdit
Left = 120
Top = 32
Width = 153
Height = 21
PasswordChar = '*'
TabOrder = 0
end
object Login: tMSButton
Left = 120
Top = 64
Width = 75
Height = 25
Caption = 'Login'
Default = True
end
object Close: tMSButton
Left = 200
Top = 64
Width = 75
Height = 25
Caption = 'Close'
end
end
EndDialog>Login
Label>login
Let>cleanPassword=password
AddDialogHandler>Login,Login,onClick,doLogin
AddDialogHandler>Login,Close,onClick,doCloseMainMenu
SetDialogProperty>Login,LoginPass,text,
Show>Login
Label>IdleLoop
Wait>0.01
If>varPassword=cleanPassword
Goto>Continue
EndIf
Goto>IdleLoop
SRT>doLogin
GetDialogProperty>Login,LoginPass,text,varPassword
CloseDialog>Login
If>varPassword<>cleanPassword
MessageModal>Password incorrect. Please try again.
SetDialogProperty>Login,LoginPass,text,
SetDialogObjectFocus>Login,LoginPass
Show>Login
EndIf
END>doLogin
SRT>doCloseMainMenu
Exit>0
END>doCloseMainMenu
Label>Continue
//login successful - continue
CloseDialog>Login
MessageModal>Main Menu