Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script ends before all actions completed

Status
Not open for further replies.

jfredmuggsjr

IS-IT--Management
Dec 17, 2002
1
US
I have a process that prompts the user for one of 4 actions then allows inquiry or file upload/download based on the dialog box option. When choosing the inquiry function, the script ends after the connection and I want to watch for the disconnect and do a pwexit to close Procomm. When choosing the option to download ALL files, the script seems to finish before the second file operation is complete. My guess is that I expect the script to act "procedurally" and I'm getting tripped up by the event driven functionality.

What's the best way to control the firing of procs to keep them in sequence?

Thanks

Relevant chunks of code below:
Code:
proc main
   when dialog 0 call Handler0         ;Handle dialog 0 events
   MakeDialog ()                       ;Display the dialog box
   switch sFunction                    ;Perform selected function
      case "All"                       ;Download all files
         connpr ()
         prlogin (DNLOADID,PASSWORD)
         getdata (sCommon)
         getdata (sCustFile)
      endcase
      case "Inquiry"
         connpacrim ()
         exitswitch
      endcase
   endswitch
endproc

proc GetData
   param string sFile
   integer iStatus
   set dnldpath "c:\bdist"             ;Path for file transfers
   transmit "sz -w 1024 "
   transmit sFile
   transmit "^M" 
   getfile ZMODEM
   iStatus = $XFERSTATUS
   while iStatus == 1
      istatus = $XFERSTATUS
      yield
   endwhile
   if iStatus == 2
      usermsg "Transfer successful"
   elseif iStatus == 3
      usermsg "Transfer failed"
   endif
endproc

proc Handler0
   integer event0                      ;ID of event in Dialog 0
   dlgevent 0 event0                   ;Query for which event happened

   switch event0                       ;Take action based on event
      case 2                           ;OK button
         exitswitch
      endcase
      case -1
      case 3                           ;Cancel button
         pwexit                        ;Exit Procomm 
      endcase
      case 10                          ;Radio group selected
         switch Radio10
            case 11                    ;Download all files
               sFunction = "All"
               statmsg "All files"
            endcase
            case 12                    ;Download inventory
               sFunction = "Inventory"
               statmsg "Inventory only"
            endcase
            case 13                    ;Send orders
               sFunction = "Orders"
               statmsg "Send orders"
            endcase
            case 14                    ;Inquiry
               sFunction = "Inquiry"
               statmsg "Inquiry"
            endcase
         endswitch
      endcase
   endswitch
if nullstr sFunction                   ;Default if no action taken
   sFunction = "All"
endif
endproc

proc MakeDialog
   Radio10 = 0
   dialogbox 0 8 20 216 156 71 sCaption 
                                       ;Dialog box style is 71
                                       ;64 - suspend script while displayed
                                       ; 4 - modeless
                                       ; 2 - movable with caption
                                       ; 1 - centered
      groupbox 1 33 15 149 96 "Select One" 
         radiogroup 10 Radio10
            radiobutton 11 50 30 100 14 "Download &All Files" 
            radiobutton 12 50 50 100 14 "Download &Inventory Only" 
            radiobutton 13 50 70 100 14 "Send &Orders" 
            radiobutton 14 50 90 100 14 "&Customer Inquiry" 
      endgroup
      pushbutton 2  34 127 68 16 "OK" OK DEFAULT
      pushbutton 3 114 127 68 16 "Cancel" CANCEL 
   enddialog 
endproc
 
So you are saying it appears the script is exiting before the second file has been completely received? Does the second transfer start at least? Is there any difference if you switch the two calls to GetData (I don't imagine that would make a difference).

You might try sticking a pause 1 statement between the two calls to GetData for a start. Everything else looks OK to me, though.


aspect@aspectscripting.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top