jfredmuggsjr
IS-IT--Management
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:
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