Archived Forum Post

Index of archived forum posts

Question:

Foxpro Progress Monitoring for Zip

Apr 11 '16 at 13:03

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


Answer


***** 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


lcOnError=ON('ERROR') &&..capture error msg *ON ERROR llFailed=.T.



*** SEND FILE




**** 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

***** 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


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"


! **** 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


**** FTP Download CallBack Procs ****

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()




Answer

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.


Answer

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 *******



Answer

And how is it in the new 9_5_0 Version ?


Answer

It works Perfect ! I have all of Chilkat's Callback ActiveX modules working in Foxpro 9 flawlessly. Been using Chilkat for years, Chilkat Rocks!


Answer

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)


Answer

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