CloseDialog not working when compiled

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
Scones
Junior Coder
Posts: 32
Joined: Fri Jul 05, 2019 11:21 am

CloseDialog not working when compiled

Post by Scones » Tue Apr 14, 2020 4:27 pm

Hello

CloseDialog doesn't seem to work in a compiled script.

Example 1: CloseDialog command is Inside an subroutine

Code: Select all

Dialog>Dialog1
object Dialog1: TForm
  Left = 408
  Top = 111
  HelpContext = 5000
  BorderIcons = [biSystemMenu]
  Caption = 'CustomDialog'
  ClientHeight = 115
  ClientWidth = 263
  Color = clBtnFace
  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 MSButton1: tMSButton
    Left = 79
    Top = 39
    Width = 105
    Height = 36
    Caption = 'Start my SRT!'
    TabOrder = 8
    DoBrowse = False
    BrowseStyle = fbOpen
  end
end
EndDialog>Dialog1

AddDialogHandler>Dialog1,MSButton1,OnClick,My_SRT

Label>Start

Show Dialog1,r

SRT>My_SRT
MDL SRT STARTED
CloseDialog>Dialog1
MDL Did the dialog close?
SkipLabel>Start
END>My_SRT
Example 2: CloseDialog command is outside a subroutine

Code: Select all

Dialog>Dialog1
object Dialog1: TForm
  Left = 408
  Top = 111
  HelpContext = 5000
  BorderIcons = [biSystemMenu]
  Caption = 'CustomDialog'
  ClientHeight = 115
  ClientWidth = 263
  Color = clBtnFace
  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 MSButton1: tMSButton
    Left = 79
    Top = 39
    Width = 105
    Height = 36
    Caption = 'Start my SRT!'
    TabOrder = 8
    DoBrowse = False
    BrowseStyle = fbOpen
  end
end
EndDialog>Dialog1

AddDialogHandler>Dialog1,MSButton1,OnClick,My_SRT

Label>Start

CloseDialog>Dialog1
MDL Did the dialog close?

Show Dialog1,r

SRT>My_SRT
MDL SRT STARTED
SkipLabel>Start
END>My_SRT
If you try these in dev mode, they should work fine, but compile it to an exe and it will not work.

Am i doing something wrong here?

User avatar
Grovkillen
Automation Wizard
Posts: 1131
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Re: CloseDialog not working when compiled

Post by Grovkillen » Tue Apr 14, 2020 5:55 pm

You are using "r" to have the dialog action captured. If you have a loop instead you may close the dialog with code.

And your code isn't the cleanest... Mind the syntax.
Let>ME=%Script%

Running: 15.0.27
version history

Scones
Junior Coder
Posts: 32
Joined: Fri Jul 05, 2019 11:21 am

Re: CloseDialog not working when compiled

Post by Scones » Tue Apr 14, 2020 9:10 pm

Thanks!

Any idea why it works in devmode and not when compiled?

User avatar
Grovkillen
Automation Wizard
Posts: 1131
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Re: CloseDialog not working when compiled

Post by Grovkillen » Wed Apr 15, 2020 4:35 am

Yes, doing it from the editor simulates the behavior since you're not actually running a true application. Thus you can do things a compiled script cannot.
Let>ME=%Script%

Running: 15.0.27
version history

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts