ADS -> AdsRegCallBack()

ADS -> AdsRegCallBack()

Postby Carles » Wed Apr 26, 2006 12:37 pm

Hola,

Alguien usa con exito esta funcion ( ADSRegCallBack() )?


Saludos.
C.
Salutacions, saludos, regards

"...programar es fácil, hacer programas es difícil..."

UT Page -> https://carles9000.github.io/
Forum UT -> https://discord.gg/bq8a9yGMWh
Skype -> https://join.skype.com/cnzQg3Kr1dnk
User avatar
Carles
 
Posts: 1101
Joined: Fri Feb 10, 2006 2:34 pm
Location: Barcelona

Postby R.F. » Wed Apr 26, 2006 3:58 pm

Haz probado asi ???:


FUNCTION Main()
...
AdsRegCallBack( {|nPercent| outputstuff(nPercent)} )
INDEX ON First+LAST+LABEL1+LABEL2 TAG First
AdsClrCallBack()
RETURN nil

FUNCTION outputstuff(nPercent) /* funcion "callback" */
? "Porcentaje de avance:", nPercent
RETURN inkey() == 27
Saludos
R.F.
R.F.
 
Posts: 840
Joined: Thu Oct 13, 2005 7:05 pm

Postby Carles » Thu Apr 27, 2006 7:48 am

Hi Rene,

Tenia una construccion similar a la tuya y no me funcionaba y llevaba 3 dias con ello, pero... te explico. Yo queria usar esta funcionalidad con la funcion ADSCopyTableContents(). La funcion en si va como un torpedo y segun su help:

Note This function is capable of utilizing registered callback functions


Y un codigo sencillo a probar podria ser

Code: Select all  Expand view
FUNCTION Main()
...
USE ORIGEN SHARED NEW
cAliasOrigen := Alias()

USE DESTINO SHARED NEW
cAliasDestino := Alias()

AdsRegCallBack( {|nPercent| outputstuff(nPercent)} )

(cAliasOrigen)->( AdsCopyTableContents( cAliasDestino ) )

AdsClrCallBack()

RETURN nil



Y venga a probar q probar y nada. En cambio lo pruebas en un ejemplo con indexados y funciona Ok. En fin, desisto ya perder mas tiempo. Sera un error del Help de ADS.

Bueno, gracias por tu feedback.

Nota: Nos tomamos prontito unas cervezas en Barcelona ? :lol:


Un abrazo
Salutacions, saludos, regards

"...programar es fácil, hacer programas es difícil..."

UT Page -> https://carles9000.github.io/
Forum UT -> https://discord.gg/bq8a9yGMWh
Skype -> https://join.skype.com/cnzQg3Kr1dnk
User avatar
Carles
 
Posts: 1101
Joined: Fri Feb 10, 2006 2:34 pm
Location: Barcelona

Postby R.F. » Thu Apr 27, 2006 4:05 pm

Carles:

Nop, no es un error del Help ADS, es simplemente que el "Callback" solo esta implementado para los índices en el RDDADS, no fuciona en ninguna otra función.... :(

Voy a ponerme en contacto con Bryan Hayes, a ver si es posible implementar llamadas callback en toras funciones.
Saludos
R.F.
R.F.
 
Posts: 840
Joined: Thu Oct 13, 2005 7:05 pm

Postby reinaldocrespo » Sat Dec 23, 2006 5:49 pm

Rene;

¿Hay noticias sobre este tema? ¿Te ha respondido Brian?

Mi intención es usarla en algo asi:

Code: Select all  Expand view
   AdsRegCallBack( { | nPercent | ProgressUpdate( nPercent ) } )

   IF ADSExecuteSQLDirect( cCons )
...


Pero observo que durante la ejecución del ADSExecuteSQLDirect la función registrada con AdsRegCallBack no es invocada. Quisiera conocer que hacer para lograr mostrar el progreso de una ejecución SQL.



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

Re: ADS -> AdsRegCallBack()

Postby Massimo Linossi » Thu Aug 09, 2012 3:25 pm

Hi Reinaldo.
Have you solved this issue ?
I have the same problem. I want to execute a function when Advantage is making a select (is only a meter for showing that the procedure is working ).
Thanks a lot.
Massimo.
User avatar
Massimo Linossi
 
Posts: 495
Joined: Mon Oct 17, 2005 10:38 am
Location: Italy

Re: ADS -> AdsRegCallBack()

Postby reinaldocrespo » Thu Aug 09, 2012 3:58 pm

It is working right now for me.

Here is the code snippet:

Code: Select all  Expand view

      IF ADSCreateSQLStatement( ::cAlias, ::nTblType, ::hAds ) //.or. !ADSVerifySQL( cScript )

               oMeter := PROGRESSBAR():New( 100, ::cProgressMsg )
               ACTIVATE DIALOG oMeter:oDlg NOWAIT ON INIT oMeter:oDlg:center( WndMain() )
               ::bProgress := { |n| oMeter:nCount++, oMeter:Update( n ) }

            Register_CallBack( { | nPercent | EVAL( ::bProgress, nPercent ) } )

             TRY 
                isgood := ADSExecuteSQLDirect( cSql )
            CATCH
                isgood := .F.
            END

            Unregister_callback()
...
 


Code: Select all  Expand view

*-------------------------------------------------------------------------------------------------------
#pragma BEGINDUMP
#include <windows.h>

#include "ace.h"
#include "hbapi.h"
#include "hbvm.h"
#include "hbapiitm.h"

UNSIGNED32 long _stdcall ShowPercentage( UNSIGNED16 usPercentDone , UNSIGNED32 ulCallbackID );

static PHB_ITEM pBlock;

//---------------------------------------------------------------------------//
HB_FUNC( REGISTER_CALLBACK )
{
   pBlock = hb_itemParam( 1 );
   hb_retni( AdsRegisterCallbackFunction( ShowPercentage , 1 ) );
}

//---------------------------------------------------------------------------//
HB_FUNC( UNREGISTER_CALLBACK )
{
   AdsClearCallbackFunction();

   if( pBlock )
   {
      hb_itemRelease( pBlock );
   }
}

//---------------------------------------------------------------------------//
UNSIGNED32 long _stdcall ShowPercentage( UNSIGNED16 usPercentDone, UNSIGNED32 ulCallbackID )
//UNSIGNED32 WINAPI ShowPercentage( UNSIGNED16 usPercentDone, UNSIGNED32 ulCallbackID )
{
   PHB_ITEM pPercent = hb_itemPutNI( NULL, usPercentDone );

   if( pPercent && pBlock)
   {
      hb_vmEvalBlockV( pBlock, 1, pPercent );
      hb_itemRelease( pPercent );
   }

   return 0;
}

 


Hope that helps,


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

Re: ADS -> AdsRegCallBack()

Postby Massimo Linossi » Thu Aug 09, 2012 4:07 pm

Thanks Reinaldo.
I'll give it a try. But not now. I have to turn off the computer because there's a storm coming and I would not take chances with electrical surges.
Massimo.
User avatar
Massimo Linossi
 
Posts: 495
Joined: Mon Oct 17, 2005 10:38 am
Location: Italy

Re: ADS -> AdsRegCallBack()

Postby Massimo Linossi » Fri Aug 10, 2012 9:56 am

Hi Reinaldo.
I made this function, appending yours, but I receive some errors during compiling process. I'm using Xharbour commercial.
I'm doing something wrong ?
Thanks a lot.
Massimo


**************************************************************************
#include "fivewin.ch"
#include "c:\xHb\include\ads.ch"


Function Girbase()

local oDlg, ometer

DEFINE DIALOG oDlg RESOURCE "UTF_TEST"

oMeter = Tprogress():Redefine(100,oDlg)

REDEFINE BUTTON ID 300 of oDlg ACTION (oDlg:End())
REDEFINE BUTTON ID 301 of oDlg ACTION (leggi_dati(@ometer))

ACTIVATE DIALOG oDlg CENTERED
dbcloseall()
return nil

**********************************
STATIC FUNCTION leggi_dati(ometer)
LOCAL stringa_sql

oMeter:SetRange( 1, 100 )

stringa_sql = "SELECT * from bollette order by utente"

Select 0
ADSCReateSqlStatement("Utenza", 1)

Register_CallBack( { | nPercent | agg_meter(@ometer, nPercent) } )

ADSExecuteSQLDirect(stringa_sql)

Unregister_callback()


browse()

return nil

*******************************************
STATIC FUNCTION agg_meter(ometer, npercent)
oMeter:Nposition = npercent
sysrefresh()

return nil


*-------------------------------------------------------------------------------------------------------
#pragma BEGINDUMP
#include <windows.h>

#include "ace.h"
#include "hbapi.h"
#include "hbvm.h"
#include "hbapiitm.h"

UNSIGNED32 long _stdcall ShowPercentage( UNSIGNED16 usPercentDone , UNSIGNED32 ulCallbackID );

static PHB_ITEM pBlock;

//---------------------------------------------------------------------------//
HB_FUNC( REGISTER_CALLBACK )
{
pBlock = hb_itemParam( 1 );
hb_retni( AdsRegisterCallbackFunction( ShowPercentage , 1 ) );
}

//---------------------------------------------------------------------------//
HB_FUNC( UNREGISTER_CALLBACK )
{
AdsClearCallbackFunction();

if( pBlock )
{
hb_itemRelease( pBlock );
}
}

//---------------------------------------------------------------------------//
UNSIGNED32 long _stdcall ShowPercentage( UNSIGNED16 usPercentDone, UNSIGNED32 ulCallbackID )
// UNSIGNED32 WINAPI ShowPercentage( UNSIGNED16 usPercentDone, UNSIGNED32 ulCallbackID )
{
PHB_ITEM pPercent = hb_itemPutNI( NULL, usPercentDone );

if( pPercent && pBlock)
{
hb_vmEvalBlockV( pBlock, 1, pPercent );
hb_itemRelease( pPercent );
}

return 0;
}



Type: C >>>xhb.exe -o"obj\GIRBASE.c" -m -n -q -gc0 -I"c:\fwh\include" -I"C:\xHB\include" -I"C:\xHB\include\w32" "c:\fw\BLU\GAS\GIRBASE.PRG"<<<

xHarbour Compiler build 1.0.0 (SimpLex)
Copyright 1999-2007, http://www.xharbour.org http://www.harbour-project.org/
Generating object output to 'obj\GIRBASE.obj'...
c:\\fw\\BLU\\GAS\\GIRBASE.PRG(59): error: Invalid type specification.
c:\\fw\\BLU\\GAS\\GIRBASE.PRG(67): warning: Operands of = have illegal types 'unsigned long __stdcall function(unsigned short, unsigned long)' and 'long int __stdcall function(unsigned short, unsigned long)'.
c:\\fw\\BLU\\GAS\\GIRBASE.PRG(82): error: Invalid type specification.

Type: C >>>Couldn't build: GIRBASE.obj<<<
Type: C >>>TMAKEOBJECT<<<
Type: C >>>TMAKEOBJECT:REFRESH<<<
Type: N >>> 1322<<<
User avatar
Massimo Linossi
 
Posts: 495
Joined: Mon Oct 17, 2005 10:38 am
Location: Italy

Re: ADS -> AdsRegCallBack()

Postby reinaldocrespo » Fri Aug 10, 2012 10:03 pm

Massimo;

I have compiled the c code with all versions of bcc. I do get one warning that can be ignored. I'm sorry I can't say why you get errors. The code is quite simple. I'm too busy these days. I'll try to come back to this subject next week if you still need help.

Best regards,


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

Re: ADS -> AdsRegCallBack()

Postby fraxzi » Mon Oct 27, 2014 8:32 am

Reinaldo,

I got warning: Parameter 'ulCallbackID' is never used in function ShowPercentage

It doesn't affect the application on run-time but annoying when compiling.. :)
Kind Regards,
Frances

Fivewin for xHarbour v18.07
xHarbour v1.2.3.x
BCC 7.3 + PellesC8 ( Resource Compiler only)
ADS 10.1 / MariaDB
Crystal Reports 8.5/9.23 DE
xMate v1.15
User avatar
fraxzi
 
Posts: 811
Joined: Tue May 06, 2008 4:28 am
Location: Philippines

Re: ADS -> AdsRegCallBack()

Postby reinaldocrespo » Mon Oct 27, 2014 1:13 pm

Hey Frances;

I confirm you are right. I would try not to worry as the code works perfectly. I will look into it soon to see if that waring can be, somehow, pacified.

Best regards,



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

Re: ADS -> AdsRegCallBack()

Postby fraxzi » Tue Oct 28, 2014 12:28 am

reinaldocrespo wrote:Hey Frances;

I confirm you are right. I would try not to worry as the code works perfectly. I will look into it soon to see if that waring can be, somehow, pacified.

Best regards,



Reinaldo.


Reinaldo,

I did this. it solves the warning.
Code: Select all  Expand view

    UNSIGNED32 long _stdcall ShowPercentage( UNSIGNED16 usPercentDone, UNSIGNED32 ulCallbackID )
    {
       PHB_ITEM pPercent = hb_itemPutNI( NULL, usPercentDone );

       if( pPercent && pBlock)
       {
          hb_vmEvalBlockV( pBlock, ulCallbackID /*1*/, pPercent );
          hb_itemRelease( pPercent );
       }

       return 0;
    }
 
Kind Regards,
Frances

Fivewin for xHarbour v18.07
xHarbour v1.2.3.x
BCC 7.3 + PellesC8 ( Resource Compiler only)
ADS 10.1 / MariaDB
Crystal Reports 8.5/9.23 DE
xMate v1.15
User avatar
fraxzi
 
Posts: 811
Joined: Tue May 06, 2008 4:28 am
Location: Philippines

Re: ADS -> AdsRegCallBack()

Postby reinaldocrespo » Tue Oct 28, 2014 1:06 pm

Frances;

Nice job. I'll use your implementation.

Thank you.


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


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 41 guests