Script stopping after closing dialog box

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 box

Post by gchichester » Fri Oct 02, 2009 4:03 pm

Can anyone please tell me why this script will not continue after I close the Dialog Box?
I confirmed that the Update Button works correctly and that the script is still running but will
not show the message box or

Code: Select all

==============================================================
#1				 SetFocus on "Open/New Shipment"
==============================================================
*/
Let>IGNORESPACES=1
Step_Delay=300
Let>vWait=0.45
Let>SW=0.15
CapsOn
Dialog>BoLDialog
  Caption=Bill of Lading Info
  Left=530
  Top=100
  Width=340
  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=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,445,75,20,2
 Button=Update,216,445,75,20,1
EndDialog>BoLDialog
Show>BoLDialog
Include>C:\CP_Macros\NewEuropeJohn\DialogAction.scp


Start of DialogAction.scp

Step_Delay=200
Let>vWait=0.50
Let>SW=0.15
Let>UpdateFlag=1
Label>ActionLoop
GetDialogAction>BoLDialog,r

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

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

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

//------------------------------------------------------------------------------DLF
 If>{(%BoLDialog.ShpName% = "DLF") AND (%BoLDialog.SLCode% = "APLU")}
       Let>SrvContNum=EXPIRED
 EndIf

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

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

//------------------------------------------------------------------------------DNE
 If>{(%BoLDialog.ShpName% = "DNE") AND (%BoLDialog.SLCode% = "APLU")}
       Let>SrvContNum=EXPIRED
 EndIf

 If>{(%BoLDialog.ShpName% = "DNE") AND (%BoLDialog.SLCode% = "CMDU")}
       Let>SrvContNum=EXPIRED
 EndIf

 If>{(%BoLDialog.ShpName% = "DNE") AND (%BoLDialog.SLCode% = "ELGV")}
       Let>SrvContNum=EXPIRED
 EndIf

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

 If>{(%BoLDialog.ShpName% = "DNE") AND (%BoLDialog.SLCode% = "HLCU")}
       Let>SrvContNum=S9NSE115
 EndIf

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

 If>{(%BoLDialog.ShpName% = "DNE") AND (%BoLDialog.SLCode% = "OOLU")}
       Let>SrvContNum=EXPIRED
 EndIf

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

//------------------------------------------------------------------------------GREENE RIVER
 If>{(%BoLDialog.ShpName% = "GREENE") AND (%BoLDialog.SLCode% = "APLU")}
       Let>SrvContNum=EXPIRED
 EndIf

 If>{(%BoLDialog.ShpName% = "GREENE") AND (%BoLDialog.SLCode% = "CMDU")}
       Let>SrvContNum=EXPIRED
 EndIf

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

 If>{(%BoLDialog.ShpName% = "GREENE") AND (%BoLDialog.SLCode% = "HLCU")}
       Let>SrvContNum=EXPIRED
 EndIf

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

//------------------------------------------------------------------------------HELLER
 If>{(%BoLDialog.ShpName% = "HELLER") AND (%BoLDialog.SLCode% = "MAEU")}
       Let>SrvContNum=385343
 EndIf

//------------------------------------------------------------------------------LEROY SMITH
 If>{(%BoLDialog.ShpName% = "LEROY") AND (%BoLDialog.SLCode% = "HJSC")}
       Let>SrvContNum=EXPIRED
 EndIf

 If>{(%BoLDialog.ShpName% = "LEROY") AND (%BoLDialog.SLCode% = "HLCU")}
       Let>SrvContNum=EXPIRED
 EndIf

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

//------------------------------------------------------------------------------PACKERS
 If>{(%BoLDialog.ShpName% = "PACKERS") AND (%BoLDialog.SLCode% = "APLU")}
       Let>SrvContNum=EXPIRED
 EndIf

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

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

 If>{(%BoLDialog.ShpName% = "PACKERS") AND (%BoLDialog.SLCode% = "OOLU")}
       Let>SrvContNum=EXPIRED
 EndIf

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

//------------------------------------------------------------------------------PREMIER
 If>{(%BoLDialog.ShpName% = "PREMIER") AND (%BoLDialog.SLCode% = "APLU")}
       Let>SrvContNum=EXPIRED
 EndIf

 If>{(%BoLDialog.ShpName% = "PREMIER") AND (%BoLDialog.SLCode% = "CMDU")}
       Let>SrvContNum=EXPIRED
 EndIf

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

 If>{(%BoLDialog.ShpName% = "PREMIER") AND (%BoLDialog.SLCode% = "HLCU")}
       Let>SrvContNum=EXPIRED
 EndIf

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

//------------------------------------------------------------------------------RIVER ONE
 If>{(%BoLDialog.ShpName% = "RIVER") AND (%BoLDialog.SLCode% = "APLU")}
       Let>SrvContNum=EXPIRED
 EndIf

//------------------------------------------------------------------------------SCOTT
 If>{(%BoLDialog.ShpName% = "SCOTT") AND (%BoLDialog.SLCode% = "APLU")}
       Let>SrvContNum=EXPIRED
 EndIf

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

 If>{(%BoLDialog.ShpName% = "SCOTT") AND (%BoLDialog.SLCode% = "HLCU")}
       Let>SrvContNum=EXPIRED
 EndIf

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

//------------------------------------------------------------------------------SEALD-SWEET
 If>{(%BoLDialog.ShpName% = "SEALD") AND (%BoLDialog.SLCode% = "APLU")}
       Let>SrvContNum=EXPIRED
 EndIf

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

 If>{(%BoLDialog.ShpName% = "SEALD") AND (%BoLDialog.SLCode% = "HLCU")}
       Let>SrvContNum=EXPIRED
 EndIf

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

//------------------------------------------------------------------------------SUNNY FRESH
 If>{(%BoLDialog.ShpName% = "SUNNY") AND (%BoLDialog.SLCode% = "APLU")}
       Let>SrvContNum=EXPIRED
 EndIf
    Length>BoLDialog.DDate,vLen
    If>{(%vlen%=6)and(%UpdateFlag%=1)},Update
    If>r=1,Update
    If>r=2,Close
GoTo>ActionLoop
Label>Exit

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

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

//Added this message for Debugging, but never get message!
MessageModal>%BoLDialog.ShpName%, %BoLDialog.SrvContract%, %BoLDialog.SLCode%

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 » Sat Oct 03, 2009 3:32 am

Let's examine your script one section at a time
Your ActionLoop will cycle forever within itself unless %vlen%=6 and %UpdateFlag%=1 or the "Update" button is pressed or the "Done" button or the Dialog "X" is pressed.

Code: Select all

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

///Many lines removed for ease of explanation///

GoTo>ActionLoop
Label>Exit
If %vlen%=6 and %UpdateFlag%=1 or the "Update" button is pressed the loop exits to the Update subroutine which performs some variable assignments and resets the dialog. Then as all good subroutines do, it passes execution back to the line following the Gosub line. So you are back in your endless ActionLoop.

Code: Select all

SRT>Update
  Let>UpdateFlag=0
  Let>BoLDialog.SrvContract=%SrvContNum%
  ResetDialogAction>BoLDialog
END>Update
If the dialog "X" or the "Done" button is pressed you escape the ActionLoop and jump to the "Close" subroutine. The dialog is closed, "r" is set to the value "2" which is redundant because it is already set to "2" or the subroutine would nat have been called. Then as all good subroutines do, it passes execution back to the line following the Gosub line. So you are back in your endless ActionLoop.

Code: Select all

SRT>Close
  CloseDialog>BoLDialog
  Let>r=2
END>Close
In other words you have not provided any way to escape your ActionLoop and get to the following message and the lines following the message

Code: Select all

//Added this message for Debugging, but never get message!
MessageModal>%BoLDialog.ShpName%, %BoLDialog.SrvContract%, %BoLDialog.SLCode%
Perhaps what you need to do is make the "Close" Subroutine a Label instead. If it is a label, processing will continue on through to the message then on to the last portion of your script.

Code: Select all

Label>Close
  CloseDialog>BoLDialog
  //Don't need Let>r=2

//Added this message for Debugging, but never get message!
MessageModal>%BoLDialog.ShpName%, %BoLDialog.SrvContract%, %BoLDialog.SLCode%

//Last lines of the script

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