Dialog not showing when executed from another script file

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
Richard
Newbie
Posts: 3
Joined: Sat Oct 23, 2010 8:53 pm

Dialog not showing when executed from another script file

Post by Richard » Sat Oct 23, 2010 9:13 pm

I use the Macro command to execute another script file. This other script file contains a dialog. The problem is that this dialog won't show. I don't know if I'm doing something wrong, or if this is a bug. I have simplyfied my code to reproduce the problem here.

The first macro file called MyDialog.scp contains a simple standard dialog with a dummy button. It has the following code:

Code: Select all

Dialog>Dialog1
object Dialog1: TForm
  Left = 2167
  Top = 96
  HelpContext = 5000
  BorderIcons = [biSystemMenu]
  Caption = 'CustomDialog'
  ClientHeight = 212
  ClientWidth = 431
  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 = 155
    Top = 81
    Width = 75
    Height = 25
    Caption = 'MSButton1'
    DoubleBuffered = True
    ParentDoubleBuffered = False
    TabOrder = 8
    DoBrowse = False
    BrowseStyle = fbOpen
  end
end
EndDialog>Dialog1

Show>Dialog1,result
let>MACRO_RESULT=1
The second Macro file, called MyTestMacro.scp, contains this code:

Code: Select all

Macro>%SCRIPT_DIR%\MyDialog.scp
MessageModal>MACRO_RESULT=%MACRO_RESULT%

When I execute the MyDialog file, the dialog shows up. When I execute the MyTestMacro file, it immediately shows the messagebox with the text MACRO_RESULT=1. But the dialog in the MyDialog file never shows.

Can anyone explain what's going wrong?

kind regards,
Richard

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Sat Oct 23, 2010 10:15 pm

Hi Richard,

I can't explain the problem but I can confirm it.

After seeing your post and copying your scripts and then witnessing that the dialog does not display, I rewrote your two scripts thinking there might be something unusual in your dialog. I got the same result. Then I went back to the pre version 12 dialog form and all works as planned. Something seems to be broken with calling a version 12 dialog using the Macro> function.

Here's a pre version 12 dialog in a script similar to your first script, that will work... or at least worked for me.

Later,
Dick

Code: Select all

Dialog>Dialog1
   Caption=Dialog1
   Width=445
   Height=250
   Top=289
   Left=291
   Button=msButton1,182,153,75,25,0
EndDialog>Dialog1


Show>Dialog1,result
let>MACRO_RESULT=1

Richard
Newbie
Posts: 3
Joined: Sat Oct 23, 2010 8:53 pm

Post by Richard » Sat Oct 23, 2010 10:28 pm

Thanks, however, the real dialog i'm using is a lot more complex and uses lots of DialogHandlers. I've found a kind of work around by including the file with the dialog functionality in the main macro file.
I'm not too keen on using the Include>... thing, because it sometimes causes problems with the debugger, but it will have to do.

Anyway, thanks for the quick response and I hope that perhaps in a next version the problem will be solved.

kind regards,
Richard.

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Sun Oct 24, 2010 1:02 am

I know the Include / debugger issue you're refering to. I believe it was resolved with version 12.

If you don't want to use Include and you can't go back to pre 12 dialogs you might also try using Run> or Execute>

Run>msched.exe %SCRIPT_DIR%\MyDialog.scp

Or just

Exe>%SCRIPT_DIR%\MyDialog.scp

In either case you can loop to wait for a response from the dialog script before continuing the calling script to cause behavior similar to the Macro> function.

Label>WaitingForDialogScriptToComplete
If>%MACRO_RESULT%1
Wait>0.01
Goto>WaitingForDialogScriptToComplete
EndIf

Richard
Newbie
Posts: 3
Joined: Sat Oct 23, 2010 8:53 pm

Post by Richard » Sun Oct 24, 2010 6:06 am

That is an interesting alternative. I might try that. It does show the dialog that way. However, it would be a bit more difficult to pass a result variable back to the calling script. You can't use the MACRO_RESULT variable, and using an exit code only works for compiled scripts, but I could probably use a registry setting or write to a file.

Thanks for the help.

kind regards,
Richard

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Mon Oct 25, 2010 12:38 pm

You can't use the MACRO_RESULT variable
Oops. You are correct, the code snippet I submitted will not work. Sorry for the misinformation. You are also correct that you could use the registry (which is a file) or write to a file of your own. You could also pass variable info via the clipboard.
Anyway, thanks for the quick response and I hope that perhaps in a next version the problem will be solved.
I agree, hopefully it will be an easy fix.

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Mon Oct 25, 2010 1:24 pm

Just to say this has been noted, replicated and is straight on the work list.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

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