Script stopping after closing dialog

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
gchichester
Pro Scripter
Posts: 132
Joined: Mon Dec 22, 2008 4:56 pm
Location: St Augustine FL

Script stopping after closing dialog

Post by gchichester » Thu Jun 04, 2009 3:11 pm

I can't seem to get the included script to continue after the Dialog is closed.
I did step through it with debug and got stuck in a loop, not sure if thats the issue or not.

Code: Select all

Let>IGNORESPACES=1
Step_Delay=300
Let>vWait=0.45
Let>SW=0.15
CapsOn
Dialog>BoLDialog
  Caption=Bill of Lading Info
  Left=430
  Top=100
  Width=310
  Height=500
 Label=Shipper Name:,10,20
 Edit=ShpName,100,20,120,
 Label=Booking Number:,10,45
 Edit=BkNum,100,45,120,
 Label=Bill of Lading #:,10,70
 Edit=BoLNum,100,70,120,
 Label=Reference:,10,95
 Edit=RefNum,100,95,120,
 Label=Carrier Code:,10,120
 Edit=SLCode,100,120,120,
 Label=Departure Date:,10,145
 Edit=DDate,100,145,120,
 Label=Loading Port:,10,170
 Edit=LPort,100,170,120,
 Label=Port of Discharge:,10,195
 Edit=DPort,100,195,120,
 Label=Vessel Name:,10,220
 Edit=VName,100,220,120,
 Label=Container #:,10,245
 Edit=ContNum,100,245,120,
 //Label= Num of Containers:,225,230
 //Edit=NumOfCont,250,245,40,
 Label=Seal Number:,10,270
 Edit=SNum,100,270,120,
 Label=Quantity:,10,295
 Edit=CtnQty,100,295,120,
 Label=Weight:,10,320
 Edit=ContWgt,100,320,120,
 Label=Service Contract:,10,345
 Edit=SrvContract,100,345,120,
 Label=Temp:,10,370
 Edit=Temp,100,370,120,
 Label=Vents:,10,395
 Edit=Vents,100,395,120,
 Label=Total Cartons:,10,420
 Edit=Cartons,100,420,120,
 Button=&Done,10,447,75,20,2
 Button=&Update,216,447,75,20,1
 Button=Use &Last,116,447,75,20,3
EndDialog>BoLDialog
Show>BoLDialog
Include>c:\CP_Macros\Europe\DialogAction.scp

//Stat of DialogAction.scp

Step_Delay=200
Let>vWait=0.50
Let>SW=0.15
Let>UpdateFlag=1
Let>StorageFile=c:\cp_macros\johnw\BolSave.ini
Label>ActionLoop
GetDialogAction>BoLDialog,r

 If>{(%BoLDialog.ShpName% = "DIVE") AND (%BoLDialog.SLCode% = "APLU")}
       Let>SrvContNum= TA08/0134
 EndIf

 If>{(%BoLDialog.ShpName% = "DIVE") AND (%BoLDialog.SLCode% = "HJSC")}
       Let>SrvContNum=ANE25230
 EndIf

 If>{(%BoLDialog.ShpName% = "DIVE") AND (%BoLDialog.SLCode% = "MAEU")}
       Let>SrvContNum=297908
 EndIf

//------------------------------------------------------------------------------
    Length>BoLDialog.DDate,vLen
    If>{(%vlen%=6)and(%UpdateFlag%=1)},Update
    If>r=1,Update
    If>r=2,Exit
    If>r=6,Close
If>r=3
GoSub>UseLast
EndIf
GoTo>ActionLoop
Label>Exit

//------------------------------------------------------------------------------
SRT>Update
  Let>UpdateFlag=0
  Let>BoLDialog.SrvContract=%SrvContNum%
  ResetDialogAction>BoLDialog
END>Update

//------------------------------------------------------------------------------
Label>Exit

//On exit, save the new values of the edit boxes to the ini file
    EditIniFile>StorageFile,Last,Box1,BolDialog.ShpName
    EditIniFile>StorageFile,Last,Box2,BolDialog.BkNum
    EditIniFile>StorageFile,Last,Box3,BolDialog.BoLNum
    EditIniFile>StorageFile,Last,Box4,BolDialog.RefNum
    EditIniFile>StorageFile,Last,Box5,BolDialog.SLCode
    EditIniFile>StorageFile,Last,Box6,BolDialog.DDate
    EditIniFile>StorageFile,Last,Box7,BolDialog.LPort
    EditIniFile>StorageFile,Last,Box8,BolDialog.DPort
    EditIniFile>StorageFile,Last,Box9,BolDialog.VName
    EditIniFile>StorageFile,Last,Box10,BolDialog.ContNum
    EditIniFile>StorageFile,Last,Box11,BolDialog.SNum
    EditIniFile>StorageFile,Last,Box12,BolDialog.CtnQty
    EditIniFile>StorageFile,Last,Box13,BolDialog.ContWgt
    EditIniFile>StorageFile,Last,Box14,BolDialog.SrvContract
    EditIniFile>StorageFile,Last,Box15,BolDialog.Temp
    EditIniFile>StorageFile,Last,Box16,BolDialog.Vents
    EditIniFile>StorageFile,Last,Box17,BolDialog.Cartons
    Exit>0

//If the ini file exists read the previously saved values
//Else create the ini file with empty values
SRT>UseLast
IfFileExists>StorageFile
    ReadIniFile>StorageFile,Last,Box1,BolDialog.ShpName
    ReadIniFile>StorageFile,Last,Box2,BolDialog.BkNum
    ReadIniFile>StorageFile,Last,Box3,BolDialog.BoLNum
    ReadIniFile>StorageFile,Last,Box4,BolDialog.RefNum
    ReadIniFile>StorageFile,Last,Box5,BolDialog.SLCode
    ReadIniFile>StorageFile,Last,Box6,BolDialog.DDate
    ReadIniFile>StorageFile,Last,Box7,BolDialog.LPort
    ReadIniFile>StorageFile,Last,Box8,BolDialog.DPort
    ReadIniFile>StorageFile,Last,Box9,BolDialog.VName
    ReadIniFile>StorageFile,Last,Box10,BolDialog.ContNum
    ReadIniFile>StorageFile,Last,Box11,BolDialog.SNum
    ReadIniFile>StorageFile,Last,Box12,BolDialog.CtnQty
    ReadIniFile>StorageFile,Last,Box13,BolDialog.ContWgt
    ReadIniFile>StorageFile,Last,Box14,BolDialog.SrvContract
    ReadIniFile>StorageFile,Last,Box15,BolDialog.Temp
    ReadIniFile>StorageFile,Last,Box16,BolDialog.Vents
    ReadIniFile>StorageFile,Last,Box17,BolDialog.Cartons
Else
    WriteLn>StorageFile,wres,[Last]
    WriteLn>StorageFile,wres,Box1=
    WriteLn>StorageFile,wres,Box2=
    WriteLn>StorageFile,wres,Box3=
    WriteLn>StorageFile,wres,Box4=
    WriteLn>StorageFile,wres,Box5=
    WriteLn>StorageFile,wres,Box6=
    WriteLn>StorageFile,wres,Box7=
    WriteLn>StorageFile,wres,Box8=
    WriteLn>StorageFile,wres,Box9=
    WriteLn>StorageFile,wres,Box10=
    WriteLn>StorageFile,wres,Box11=
    WriteLn>StorageFile,wres,Box12=
    WriteLn>StorageFile,wres,Box13=
    WriteLn>StorageFile,wres,Box14=
    WriteLn>StorageFile,wres,Box15=
    WriteLn>StorageFile,wres,Box16=
    WriteLn>StorageFile,wres,Box17=
EndIf

//Reset Dialog1 to reflect the predefined edit box variables
ResetDialogAction>BolDialog
END>UseLast

SRT>Close
  CloseDialog>BoLDialog
  Let>r=2
END>Close
Wait>vWait


Script will not continue from here

/*
==========================================================================
#1   		                       Wait for Open/New Shipment window to SetFocus
==========================================================================
*/
Wait>0.30
SetFocus>Open/New Shipment*
Wait>0.30
CapsOff

/*
==========================================================================
#2   		      Press Key ALT-2 - To Start New "Vessel Container" Shipment
==========================================================================
*/
Press ALT
Send>2
Release Alt

/*
==========================================================================
#3 							Move Cusor to "Vessel Container" in ListBox 
==========================================================================
*/
Wait>SW
Press Shift
Press Tab
Wait>SW
Press Tab
Wait>SW
Release Shift
Wait>SW
Press Down * 2
Wait>vWait

/*
===========================================================================
#4 							Pree Key  ALT-u to Select Auto Button
===========================================================================
*/
Press ALT
Send>{"u"}
Release ALT
Wait>vWait

/*
===========================================================================
#5 							Press Key  ALT-r to Select Create Button
===========================================================================
*/
Press ALT
Send>{"r"}
Release ALT
//WaitKeyDown>VK123
//WaitWindowOpen>Export Manager*

/*
===========================================================================
#6    Enter Booking Number - Wait for F12 - Press Tab, Enter to accept popup window
===========================================================================
*/
Wait>vWait
Send>%BoLDialog.BkNum%
Wait>vWait
Press Tab
//Let>WF_TYPE=3
WaitWindowOpen>Export Manager
Wait>vWait
Press Enter
//WaitKeyDown>VK123
Include>C:\CP_Macros\NewEuropeJohn\2_CopyTemplate.scp


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

Post by JRL » Thu Jun 04, 2009 3:53 pm

Perhaps I'm not understanding your question....but.

When you select the "Done" button or select the upper right hand "X" the dialog closes AND your script ends. The included script "c:\CP_Macros\Europe\DialogAction.scp" is part of this script. If your main script ends so does the included script.

If you want to run the included script on exit from the dialog, perhaps you instead need to use the Macro> function somewhere in the "end sequence". For example when you select the "Done" button the button result variable "r" is set to 2. When "r" is set to 2 the script jumps to the "Exit" label. This is what I call your "end sequence". Under the "Exit" label is a string of commands that you want to perform on exit from the script. One of these commands could perhaps be:

Macro>c:\CP_Macros\Europe\DialogAction.scp

There might be a better way depending on what is in your included script.

gchichester
Pro Scripter
Posts: 132
Joined: Mon Dec 22, 2008 4:56 pm
Location: St Augustine FL

Script stopping after closing dialog

Post by gchichester » Thu Jun 04, 2009 5:59 pm

I got the jest if the "end sequence", but I still must be missing something. because this script
closes the dialog and continues running after selecting the "Done" button.
Is there a difference between "exit" and "close" ?

Code: Select all

Let>IGNORESPACES=1
Let>WW_TIMEOUT=5
Let>vWait=0.30
CapsOn
Dialog>BoLDialog
  Caption=Asia Bill of Lading Info
  Left=630
  Top=200
  Width=340
  Height=575
 Label=Shipper Name:,10,25
 Edit=ShpName,110,25,120,
  Label=Contract Customer:,10,50
 Edit=SCC,110,50,120,
  Label=Booking Number:,10,75
 Edit=BkNum,110,75,120,
  Label=Bill of Lading #:,10,100
 Edit=BoLNum,110,100,120,
  Label=Reference:,10,125
 Edit=RefNum,110,125,120,
  Label=Carrier Code :,10,150
 Edit=SLCode,110,150,120,
  Label=Departure Date:,10,175
 Edit=DDate,110,175,120,
  Label=Loading Port:,10,200
 Edit=LPort,110,200,120,
  Label=Port of Discharge:,10,225
 Edit=DPort,110,225,120,
  Label=Vessel Name:,10,250
 Edit=VName,110,250,120,
  Label=Container #:,10,275
 Edit=ContNum,110,275,120,
  //Label= Num of Containers:,225,300
 //Edit=NumOfCont,250,300,40,
  Label=Seal Number:,10,300
 Edit=SNum,110,300,120,
  Label=Quantity:,10,325
 Edit=ContQty,110,325,120,
  Label=Weight:,10,350
 Edit=ContWgt,110,350,120,
  Label=Service Contract:,10,375
 Edit=SrvContract,110,375,120,
  Label=Temp:,10,400
 Edit=Temp,110,400,120,
  Label=Vents:,10,425
 Edit=Vents,110,425,120,
  Label=Total Cartons:,10,450
 Edit=Tctns,110,450,120,
  Label=Gross Weight:,10,475
 Edit=GrsWgt,110,475,120,
Button=Done,70,510,75,20,2
Button=Update,155,510,75,20,1
EndDialog>BoLDialog
Show>BoLDialog
Include>c:\CP_Macros\MaryK\NewAsia\DialogAction_AMK.scp

This is the begging of “DialogAction_AMK.scp
Step_Delay=200
Let>vWait=0.50
Let>SW=0.15
Let>UpdateFlag=1
Label>ActionLoop
GetDialogAction>BoLDialog,z
//------------------------------------------------------------------------------CELSUS

 If>{(%BoLDialog.SCC% = "CELSUS") AND (%BoLDialog.SLCode% = "ELGV")}
       Let>SrvContNum=35378
 EndIf

 If>{(%BoLDialog.SCC% = "CELSUS") AND (%BoLDialog.SLCode% = "MAEU")}
       Let>SrvContNum=271912
 EndIf

    Length>BoLDialog.DDate,vLen
    If>{(%vlen%=6)and(%UpdateFlag%=1)},Update
    If>z=1,Update
    If>z=2,Exit
    If>z=6,Close
GoTo>ActionLoop
Label>Exit

SRT>Update
  Let>UpdateFlag=0
  Let>BoLDialog.SrvContract=%SrvContNum%
  ResetDialogAction>BoLDialog
END>Update

SRT>Close
  CloseDialog>BoLDialog
  Let>z=2
END>Close

Wait>0.30
SetFocus>Open/New Shipment*
Wait>0.30

/*
=======================================================================
#1   		      Press Key ALT-2 - To Start New "Vessel Container" Shipment
=======================================================================*/
Press ALT
Send>2
Release Alt

/*
=======================================================================
#2 				Move Cusor to "Vessel Container" in ListBox 
=======================================================================*/
Wait>SW
Press Shift
Press Tab
Wait>SW
Press Tab
Wait>SW
Release Shift
Wait>SW
Press Down * 2
Wait>vWait

/*
=======================================================================
#3 				 Press Key  ALT-u to Select Auto Button
=======================================================================*/
Press ALT
Send>u
Release ALT
Wait>vWait


/*
=======================================================================
#4 				Press Key  ALT-r to Select Create Button
=======================================================================*/
Press ALT
Send>r
Release ALT
//WaitKeyDown>VK123
WaitWindowOpen>Export Manager*

/*
=======================================================================
#5                         Enter Booking Number - Wait for F12 - Press Tab, Enter to accept popup window
=======================================================================*/
Wait>vWait
Send>%BoLDialog.BkNum%
Wait>vWait
Press Tab
Let>WF_TYPE=3
WaitWindowOpen>Export Manager
Wait>vWait
Press Enter
//WaitKeyDown>VK123
Include>C:\CP_Macros\MaryK\NewAsia\2_CopyTemplate_AMK.scp


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

Post by JRL » Thu Jun 04, 2009 6:23 pm

Is there a difference between "exit" and "close" ?
In this last posting, "Exit" is a label and "Close" is a subroutine and the script does different things after each is called. From a Macro Scheduler function point of view, there is an Exit> function that immediately terminates a script. There is no "Close" function. However there is a CLoseDialog> function and a CLoseWindow> function. These do just what they say.

Your Close subroutine is called when z=6 but I don't see any line that would set z equal to 6 so the subroutine will never be called.

Your Exit label is hanging out just below the end of the "ActionLoop". All of the lines following the label named "Exit" except the lines inside of subroutines, will be executed when the "Done" button or "X" is pressed from your dialog. That includes another included file at the end of the script.

If your script reached a last line and ended it would finish, if it is not finishing there must be a loop or a wait in the last included dialog.


I hadn't noticed at first but your previously posted script has two "Exit" labels but because of the location and order of them the script would still behave as if there was only one. The line that was exiting the script has been removed form this last posting.

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