register callback func to be exec from inside c VM harbour

register callback func to be exec from inside c VM harbour

Postby reinaldocrespo » Sun May 28, 2023 9:18 pm

Hello everyone;

I'm looking to register a callback function so that I may show some message while something is happening inside a VM c harbour function. For example to show a progress bar while the Harbour VM c function is inside a for loop.

For example:
Code: Select all  Expand view
#define CLAIMKEY_REGEX  "CL[1-2][0-9]-[0-9]{8}"
//----------------------------------------------------------------------------//
METHOD FetchFromScanner() CLASS TBatchPayments
   Local cText := TOCRFromScanner( {|n| ::ShowProgress(n) } )
   Local aOCRClaimKeys := {}
   Local aClaimKeys
 


Then have the c Wrapper TOCRFromScanner receive and execute ShowProgress inside the for loop.


Any ideas?

Thank you.
User avatar
reinaldocrespo
 
Posts: 972
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL

Re: register callback func to be exec from inside c VM harbour

Postby Antonio Linares » Mon May 29, 2023 10:41 am

Dear Reinaldo,

You may try with:

hb_idleAdd( {|n| ::ShowProgress(n) } )
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: register callback func to be exec from inside c VM harbour

Postby reinaldocrespo » Mon May 29, 2023 3:50 pm

Saludos maestro y gracias por la sugerencia.

I'm sorry I wasn't more specific.

Consider this declaration:
Code: Select all  Expand view
//-------------------------------------------------------------------------------
HB_FUNC( TOCRFROMSCANNER )
{
   TOCRJOBINFO_EG    JobInfo_EG;
   TOCRRESULTSEX_EG* Results = 0;
    long                JobNo;
    long                Status;
    long                NumImages = 0;
    long                CntImages = 0;
    HANDLE          *hMems;
    HANDLE          hMMF = 0;
   HB_WCHAR       Msg[10240];  
   HB_WCHAR       FullText[10240] = L"\n"; //final returning string
   char           LogMsg[ TOCRJOBMSGLENGTH ] ;
   HB_WCHAR       pageBreak = L'\u000C';

   memset( Msg, 0, sizeof( Msg ) );  //make sure Msg is empty
   trimTrailing(FullText);
...

               for (long ImgNo = 0; ImgNo < NumImages; ImgNo++) {

                  //show progress using a callback func here
                  //callback func registered from harbour calling func.

                  if ( hMems[ImgNo] ) {

                     sprintf( LogMsg, "Processing image # %ld.", ImgNo );
                     LogData( "TOCRerr.log", LogMsg, MAX_LOG_SIZE ) ;

                     // convert the memory block to a Memory Mapped File
                     hMMF = ConvertGlobalMemoryToMMF( hMems[ ImgNo ] );
...
 


I think in order to be able to call a progress function from inside the for loop, we would need to register a callback function that can update a progress bar declared on the calling .prg.

On the Harbour forum Laiton suggested taking a look at hbcurl source where there seems to be something similar. I will try to investigate that.

I will try any other suggestion.

Thank you.
User avatar
reinaldocrespo
 
Posts: 972
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 99 guests