Shell script runs subroutine when supposed to close

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
ZeitenWanderer
Pro Scripter
Posts: 68
Joined: Wed Dec 07, 2005 7:13 am

Shell script runs subroutine when supposed to close

Post by ZeitenWanderer » Sun May 20, 2007 10:04 am

Hi everyone,

I wrote a tiny script to call script subroutines. This one works as a shell for other scripts, everything fine so far.

But, when I hit the window button "x" to close that shell window, without or after having pushed a button, it always runs one of the called routines ("Setup") ...

Any idea, where I am messing up?


Let>APP_TITLE=DARP SHELL

Dialog>MyDialog
Caption=DARP Shell
Width=653
Height=250
Top=104
Left=16
Button= ,288,24,185,73,1,%SCRIPT_DIR%\Orders.bmp,Ruft Bestellungen ab / Picking orders
Button= ,288,112,185,73,2,%SCRIPT_DIR%\setup.bmp,Einstellungen vornehmen / Set it up
Image=,448,288,105,105
EndDialog>MyDialog

Show>MyDialog,result

If>result=1,Email-Orders
If>result=2,Setup

SRT>Setup
Macro>%SCRIPT_DIR%\setup.scp
END>Setup

SRT>Email-Orders
Macro>%SCRIPT_DIR%\order_email_holen.scp
End>Email-Orders

Show>MyDialog,result

User avatar
Rain
Automation Wizard
Posts: 550
Joined: Tue Aug 09, 2005 5:02 pm
Contact:

Post by Rain » Sun May 20, 2007 11:31 am

If>result=2,Setup
2 is always used by the X button.

Add another button for the Setup subroutine.
If>result=1,Email-Orders
If>result=2,Exit
If>result=3,Setup

ZeitenWanderer
Pro Scripter
Posts: 68
Joined: Wed Dec 07, 2005 7:13 am

Where would I find more info of that kind?

Post by ZeitenWanderer » Sun May 20, 2007 11:49 am

Thanks!! That helps.

Where would I find a detailled list, concerning system window-values? I immediately checked the help under System Variables, but it did not contain this info. Where else could it be found?

Appreciate the help. :-) Thank you very much.

User avatar
jpuziano
Automation Wizard
Posts: 1085
Joined: Sat Oct 30, 2004 12:00 am

Post by jpuziano » Sun May 20, 2007 12:05 pm

Rain wrote:If>result=2,Setup
2 is always used by the X button.

Add another button for the Setup subroutine.
If>result=1,Email-Orders
If>result=2,Exit
If>result=3,Setup
Thanks Rain... that's another good one to remember. I think I've seen other posts from users having problems with using 2 for something else before. "Clicking X on the dialog produces a 2"... That's important to know so I thought this info would be in the Help file in the "dialog" topic... so I checked and see the examples there do use 2 as the value to "End" or "exit" but I can't see where it says clicking the X on the dialog produces a 2.

Marcus, did I miss this or is it mentioned somewhere else in the Help file? If not, could a note to this effect be added to the "dialog" topic in the Help file (and on-line Help)? Please and thanks.
jpuziano

Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post - :-)

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Sun May 20, 2007 5:17 pm

In the Help for GetDialogAction it says:
"When the dialog is closed r is set to 2."

The value of r is always reset to 2.
The value of r only changes when a button is clicked.

I agree that it is not SHOUTING out what happens. And the Non-Modal example of Help for Dialog does show the values for the two buttons (5,6) with the value of 2 also added.

So the rule of thumb is that any time you are using buttons, you should include the value of 2 for exiting. You can still have an Exit Button with the value of 2 to provide a "normal" exit method.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

User avatar
jpuziano
Automation Wizard
Posts: 1085
Joined: Sat Oct 30, 2004 12:00 am

Post by jpuziano » Sun May 20, 2007 10:16 pm

Bob Hansen wrote:In the Help for GetDialogAction it says:
"When the dialog is closed r is set to 2."

The value of r is always reset to 2.
The value of r only changes when a button is clicked.

I agree that it is not SHOUTING out what happens. And the Non-Modal example of Help for Dialog does show the values for the two buttons (5,6) with the value of 2 also added.

So the rule of thumb is that any time you are using buttons, you should include the value of 2 for exiting. You can still have an Exit Button with the value of 2 to provide a "normal" exit method.
Thanks Bob for the above.

It seems to me that if a new user were building a script using the Non-Modal dialog example in the "dialog" Help topic, that uses the GetDialogAction> command so, if they read about that in Help, they should see the line...
  • When the dialog is closed r is set to 2.
...so they'd probably pick up on this.

However, if the new user used the Modal example in the Help file "dialog" topic... that doesn't use GetDialogAction> so they may not realize that 2 is "hard-coded" into the behavior of every dialog... and that clicking the Windows X Close button actually generates a 2.

The fact that we occasionally see posts like this one is proof users sometimes miss this.

However, if a line was added right into the "dialog" topic in the Help file to explain it, I believe it would help new users with this... just my opinion.

Thanks for the detailed reply and take care.
jpuziano

Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post - :-)

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 May 21, 2007 6:55 am

This is made clear in the topics for Show and GetDialogAction. These are the only functions which return this result. That's why this is stated in these topics. However, a note will be added in the Dialog topic also.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

User avatar
jpuziano
Automation Wizard
Posts: 1085
Joined: Sat Oct 30, 2004 12:00 am

Post by jpuziano » Mon May 21, 2007 9:18 am

mtettmar wrote:a note will be added in the Dialog topic also.
Thanks Marcus
jpuziano

Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post - :-)

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