Archived Forum Post

Index of archived forum posts

Question:

Visual foxpro events percentdone returning a string

Apr 11 '16 at 13:04

PercentDone return a status message not a value...

So when I check the value of nProgress it is "SocketConnect" and other messages.

Can anyone help or is this a bug?

Here is the code.

*Definition of control class:
DEFINE CLASS Ctrl as Session OLEPUBLIC

*The IMPLEMENTS... line below is what makes Foxpro take control over the SendPercentDone, ReadPercentDone and AbortCheck
*NOTE - This path part of the IMPLEMENTS must point to the dll, so locate and correct it before you are using the program.
IMPLEMENTS _IChilkatEvents IN "libs\chilkatax-9.5.0-win32.dll"

nProgress = 0
llAbort = 0

PROCEDURE Init
ENDPROC

PROCEDURE _IChilkatEvents_PercentDone(percentDone AS Number, abort AS Number) AS VOID;
    HELPSTRING "method SendPercentDone"
    * add user code here
    This.nProgress = percentDone
    ACTIVATE SCREEN
    @0,0 say "Percent Done: " + TRANSFORM(This.nProgress)
    DOEVENTS
ENDPROC

PROCEDURE _IChilkatEvents_ProgressInfo(percentDone AS Number, abort AS Number) AS VOID; HELPSTRING "method ReadPercentDone" * add user code here This.nProgress = percentDone @0,0 say "Progress: " + TRANSFORM(This.nProgress) DOEVENTS ENDPROC

PROCEDURE _IChilkatEvents_AbortCheck(abort AS Number) AS VOID; HELPSTRING "method AbortCheck" * add user code here IF THIS.llAbort = 1 abort = 1 ENDIF ENDPROC


Answer

Sorted it...

My fault... getting too caught up with it failing and not looking at the code. I was using the same variable progressDone in the progressInfo procedure.

Updated my code to...

*Definition of control class:
DEFINE CLASS Ctrl as Session OLEPUBLIC

*The IMPLEMENTS... line below is what makes Foxpro take control over the SendPercentDone, ReadPercentDone and AbortCheck
*NOTE - This path part of the IMPLEMENTS must point to the dll, so locate and correct it before you are using the program.
IMPLEMENTS _IChilkatEvents IN "libs\chilkatax-9.5.0-win32.dll"

nProgress = 0
cProgress = ""
llAbort = 0

PROCEDURE Init
ENDPROC

PROCEDURE _IChilkatEvents_PercentDone(percentDone AS Number, abort AS Number) AS VOID;
    HELPSTRING "method SendPercentDone"
    * add user code here
    This.nProgress = percentDone
    ACTIVATE SCREEN
    @0,0 say "Percent Done: " + TRANSFORM(This.nProgress)
    DOEVENTS
ENDPROC

PROCEDURE _IChilkatEvents_ProgressInfo(progressInfo AS Number, abort AS Number) AS VOID; HELPSTRING "method ReadPercentDone" * add user code here This.cProgress = progressInfo @0,0 say "Progress: " + TRANSFORM(This.nProgress) DOEVENTS ENDPROC

PROCEDURE _IChilkatEvents_AbortCheck(abort AS Number) AS VOID; HELPSTRING "method AbortCheck" * add user code here IF THIS.llAbort = 1 abort = 1 ENDIF ENDPROC

ENDDEFINE


Answer

I have question to the IOMPLEMENT. I found out the new style to write the implements with the new single dll of chilkat. BUT: how connect it with the eventhandler to VFP?

I have the implemnt like you, same name...and 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