Question:
I read your Chilkat Zip Activex has the capabilities of showing the user progress monitoring while zipping/unzipping
Do you have a Visual Foxpro example of: zip/unzip progress monitoring
Please forgive me if I have overlooked a pre-existing example
***** begin of testimg area ! DO procchk ! setsys() ! Local lcFtpType ! lcFtpType='U' &&..upload
! * upload ! IF lcFtpType='U' ! lcFile = "d:AppNamebackupsTESTBIGFTP.ZIP" ! lcFileThere = JUSTFNAME(lcFile)
! ELSE
! * download ! lcFile = "d:AppNametempTESTBIGFTP.ZIP" ! lcFileThere = JUSTFNAME(lcFile) ! ENDIF
! ? FtpCertTest(lcFile,'D') &&..U=UPLOAD D=DOWNLOAD ! RETURN ! FUNCTION FtpCertTest ***** end of testimg area begin PARAMETERS tcFileHere,tcFtpOpt tcFileHere is file to upload/download * tcFtpOpt = 'U'=upload 'D'=download
set vars ! DO procchk ! setsys() PRIVATE pnThermCnt,pnRecs,plStarted,pcTitle pnThermCnt=1 pnRecs=100 plStarted=.F. LOCAL llOK,lcUserName,lcPassword,lcIpAddress,lcPort,lcOnError,llFailed,; loFtp,lnSuccess,loCert,lcFileHere,lcFileThere,lnWkArea,lcProcs,lcFtpOpt,lcRemoteDir lcFtpOpt=IIF(TYPE('tcFtpOpt')='L','U',tcFtpOpt) lnSuccess=0 lnWkArea=SELECT() lcFileHere=gcAppPath+'FTPOUT'+JUSTFNAME(ALLTRIM(tcFileHere)) lcFileThere=JUSTFNAME(lcFileHere) lcRemoteDir='' tcTitle=''
get login settings dbopen('sysinfo') &&..stored info in a DBF file lcUserName = ALLTRIM(qFtpUser) &&..get login,password,ip,port from sysinfo vars lcPassword = ALLTRIM(qFtpPw) lcIpAddress = ALLTRIM(qFtpIp) lcPort = ALLTRIM(qFtpPort) && Default FTP PORT SELECT(lnWkArea)
lcOnError=ON('ERROR') &&..capture error msg *ON ERROR llFailed=.T.
*** SEND FILE
create object loFtp = CREATEOBJECT('Chilkat_9_5_0.Ftp2')
unlock component lnSuccess = loFtp.UnlockComponent("your unlock code") IF (lnSuccess <> 1) MESSAGEBOX('Could not Unlock ChilKatFTP2!',64,'Message') EXIT ENDIF
The EVENTHANDLER tells the COM object to send events to the VFP object: EVENTHANDLER(loFtp,loCtrl)
set login and website loFtp.HOSTNAME = lcIpAddress loFtp.Username = lcUserName loFtp.PASSWORD = lcPassword
Set timeouts - in seconds/milliseconds - added 3-24-13 loFtp.CONNECTTIMEOUT= gnFtpTimeOut &&..default 5 seconds - number of seconds loFtp.IdleTimeoutMs = gnFtpIdle &&..default 5000 - 5 seconds - number of milliseconds
**** added for new chilkat 950 * If this example does not work, try using passive mode * by setting this to 1. loFtp.Passive = 0
IF 'BAYOU' $ gcqCompany .or. 'BOO' $ gcqCompany .or. 'BOO2' $ gcqCompany loFtp.AuthTls = 0 ELSE loFtp.AuthTls = 1 ENDIF
**** added for new chilkat 950 * Indicate that the FTP server must have a verifiable SSL certificate. * Do not accept self-signed certs or certificates that are * expired, revoked, or cannot be verified to a root authority: * loFtp.RequireSslCertVerify = 1 &&..1=dont accept self-signed, 0=accept self-signed
loFtp.SetSslCertRequirement("subjectcn","AppNameWebName.com")
Connect and login to the FTP server. lnSuccess = loFtp.CONNECT() IF (lnSuccess <> 1) MESSAGEBOX('Could not connect to server!',64,'Message') EXIT ENDIF
After logging on, you may examine the FTP server's cert: loCert = loFtp.GetSslServerCert() IF (loCert = NULL ) WAIT CLEAR MESSAGEBOX("No server certificate! - Connection is not secure! Disconnecting") EXIT ELSE
***** UPLOAD ***** IF lcFtpOpt='U' pcTitle='Uploading' * Change Directory AppNameFTPIN lnSuccess = loFtp.ChangeRemoteDir("IN") IF (lnSuccess <> 1) MESSAGEBOX('Could not change to directory: IN',64,'Message') EXIT ENDIF
* Upload a file
lnSuccess = loFtp.PUTFILE(lcFileHere,lcFileThere) &&..must used exact path/filename
IF (lnSuccess <> 1)
MESSAGEBOX('Could not Upload file',64,'Message')
EXIT
ENDIF
ELSE
************************** DOWNLOAD **************************
pcTitle='Downloading'
* Change Directory \AppName\FTP\IN
*lcStrXml = loFtp.DirTreeXml() &&..used for testing
lnSuccess = loFtp.ChangeRemoteDir("OUT")
IF (lnSuccess <> 1)
MESSAGEBOX('Could not change to directory: OUT',64,'Message')
EXIT
ENDIF
* get remote directory
*lcRemoteDir=loFtp.GetCurrentRemoteDir() &&..used for testing
lnSuccess = loFtp.GETFILE(lcFileThere,lcFileHere)
IF (lnSuccess <> 1)
MESSAGEBOX('Could not Downloaded file',64,'Message')
EXIT
ENDIF
ENDIF
exit out EXIT ENDDO
disconnect loFtp.Disconnect()
was it successful? 1=successful, anything else means failed IF lnSuccess=1 llOK=.T. ENDIF
WAIT CLEAR ThermFtpSend() RELEASE loFtp,loCtrl ON ERROR &lcOnError &&..reset ON ERROR SET PROC TO genproc RETURN llOK eof: FtpSend.prg
**** function ThermFtpSend() show progress bar/ to close: ThermFtpSend() by itself or therm(.F.) syntax: ThermFtpSend(.t.,prec/rectot100,msg) ie: ! LOCAL lnThermCnt ! lnThermCnt=1 ! * update therm ! SET DEVICE TO SCREEN ! therm(.T.,((lnThermCnt/pnRecs)100),pcRptName) ! therm(.T.,((lnThermCnt/pnRecs)100),pcRptName) ! lnThermCnt=lnThermCnt+1 ! SET DEVICE TO PRINTER ! * close therm ! therm(.T.,100,'') ! therm(.T.,100,'') ! INKEY(1) !* therm() FUNCTION ThermFtpSend PARAMETERS tlActive, tnPercent, tcMsg &&..tlUpdate
DO CASE
CASE ! tlActive .AND. WEXIST("pcdoneW0") .OR. PARAMETERS()=0 .AND. WEXIST("pcdoneW0") @ 3.846,5.800 TO 4.538, 64.6-58.8*(1-100/100) PATTERN 1 PEN 1, 8 COLOR RGB(,,,255,196,230) &&..COLOR RGB(,,,128,0,0) INKEY(1) RELEASE WINDOW pcdonew0 SET CURSOR ON RETURN .T.
CASE PARAMETERS()=0 RELEASE WINDOW pcdonew0 SET CURSOR ON RETURN .T.
RETURN .T. ENDFUNC * eofunc: ThermFtpSend()
**** Define Class FtpSendCtrl methods for callback for ftp * Definition of control class: DEFINE CLASS Ftp2SendCtrl AS SESSION OLEPUBLIC IMPLEMENTS _IChilkatFtp2Events IN "ChilkatAx-9.5.0-win32.dll" &&.."old ChilkatFTP2.dll"
init PROCEDURE INIT DOEVENTS ENDPROC
AbortCheck
DOEVENTS ENDPROC
ProgressInfo
@ 2,10 SAY 'ProgressInfo cValue: '+ALLTRIM(cValue) ? 'ProgressInfo cName: '+ALLTRIM(cName) ? 'ProgressInfo cValue: '+ALLTRIM(cValue) ENDPROC
PercentDone
INKEY(.1) ENDPROC
VerifyDeleteDir PROCEDURE _IChilkatFtp2Events_VerifyDeleteDir(DirPath AS STRING, SkipFileDir AS NUMBER) AS VOID; HELPSTRING "method VerifyDeleteDir"
DOEVENTS ENDPROC
VerifyDeleteFile PROCEDURE _IChilkatFtp2Events_VerifyDeleteFile(FilePath AS STRING, SkipFileDir AS NUMBER) AS VOID; HELPSTRING "method VerifyDeleteFile"
! **** FTP Upload CallBack Procs *** ! * PutProgress ! PROCEDURE _IChilkatFtp2Events_PutProgress(PctDone AS NUMBER) AS VOID; ! HELPSTRING "method PutProgress" ! ThermFtpSend(.T.,((PctDone/pnRecs)100),'UpLoading') ! * ? 'PutProgress' ! DOEVENTS !* ENDPROC
DOEVENTS ENDPROC
EndUploadFile PROCEDURE _IChilkatFtp2Events_EndUploadFile(FilePath AS STRING, numBytes AS NUMBER) AS VOID; HELPSTRING "method EndUploadFile"
add user code here @ 6,10 SAY 'Bytes Uploaded: '+ALLTRIM(STR(ByteCount)) @ 7,10 SAY ' Bytes Per Sec: '+ALLTRIM(STR(BytesPerSec)) ENDPROC
VerifyUploadDir PROCEDURE _IChilkatFtp2Events_VerifyUploadDir(DirPath AS STRING, SkipFileDir AS NUMBER) AS VOID; HELPSTRING "method VerifyUploadDir" *DOEVENTS ENDPROC
**** FTP Download CallBack Procs ****
? 'BeginDownloadFile' *DOEVENTS ENDPROC
EndDownloadFile PROCEDURE _IChilkatFtp2Events_EndDownloadFile(FilePath AS STRING, numBytes AS NUMBER) AS VOID; HELPSTRING "method EndDownloadFile"
PROCEDURE _IChilkatFtp2Events_GetProgress(percentDone AS NUMBER) AS VOID;
! * GetProgress ! PROCEDURE _IChilkatFtp2Events_GetProgress(percentDone AS NUMBER) AS VOID; ! HELPSTRING "method GetProgress" ! * ? 'GetProgress' ! ThermFtpSend(.T.,((percentDone/pnRecs)100),'DownLoading') ! DOEVENTS !* ENDPROC
ENDDEFINE * eoClass: FtpSendCtrl()
I'm very sorry for the lack of documentation for event callbacks. It is on our long "TO DO" list.
A general discussion of using ActiveX event callbacks in Foxpro is at this Chilkat blog post: http://www.cknotes.com/?p=118
The ActiveX events (in IDL format) are listed here: http://www.cknotes.com/?p=119
Any argument that is a "long *" named "skip", "exclude", or "abort" are arguments that your application may set to 1 to skip, or exclude the next file, or to abort the entire operation.
Matt...thanks for info:
however _IChilkatZip2Events_SkippedForUnzip is missing when CTRL is instantiated below is the list you gave me...using IDL I need tge PARAMETERS for: _IChilkatZip2Events_SkippedForUnzip() also, are there any OTHER Methods missing???
Zip: dispinterface _IChilkatZip2Events { properties: methods:
HRESULT UnzipPercentDone([in] long percentDone, [out] long *abort);
HRESULT WriteZipPercentDone([in] long percentDone, [out] long *abort);
HRESULT AddFilesEnd();
HRESULT FileUnzipped([in] BSTR filename, [in] long compressedSize, [in] long uncompressedSize, [out] long abort); HRESULT ToBeAdded([in] BSTR filename, [in] long fileSize, [out] long exclude);
HRESULT FileAdded([in] BSTR filename, [in] long fileSize, [out] long *abort);
HRESULT UnzipBegin();
HRESULT UnzipEnd();
HRESULT WriteZipBegin();
HRESULT WriteZipEnd();
HRESULT ToBeZipped([in] BSTR filename, [in] long fileSize, [out] long *exclude);
HRESULT FileZipped([in] BSTR filename, [in] long fileSize, [in] long compressedSize, [out] long *abort);
HRESULT ToBeUnzipped([in] BSTR filename, [in] long compressedSize, [in] long uncompressedSize, [out] long *exclude);
HRESULT AddFilesBegin(); };
****** FOXPRO CODE BEGIN OF ZIP-CALLBACK *****
ENDPROC
*** MATT I NEED THE PARAMETERS * SkippedForUnzip * HRESULT SkippedForUnzip() PROCEDURE _IChilkatZip2Events_SkippedForUnzip(FileName AS NUMBER,Abort AS NUMBER,) AS VOID; HELPSTRING "method SkippedForUnzip" * add user code here ? 'SkippedForUnzip' ENDPROC
ENDDEFINE
****** END OF ZIP-CALLBACK *******
And how is it in the new 9_5_0 Version ?
It works Perfect ! I have all of Chilkat's Callback ActiveX modules working in Foxpro 9 flawlessly. Been using Chilkat for years, Chilkat Rocks!
But can you post a little example?
I wrote in an other blog: I wrote in VFP :
loFtp = CreateObject('Chilkat_9_5_0.Ftp2') ... loCtrl = CREATEOBJECT("ChilkatCtrl") && Create controlling object:
EVENTHANDLER(toFTP, loCtrl)
but EVENTHANDLER return .F. and nothing is fired in the events.. Any sample code for me would be great beacuse chilkat has nothing there for the new version (i coundln't find)
I generated .prg samples/templates for each of the Chilkat ActiveX classes that have events. See http://www.chilkatforum.com/questions/10182/chilkat-foxpro-events-prg-event-classes