FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour ADS -> AdsRegCallBack()
Posts: 1283
Joined: Fri Feb 10, 2006 02:34 PM
ADS -> AdsRegCallBack()
Posted: 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
HIX -> https://github.com/carles9000/hix
Posts: 840
Joined: Thu Oct 13, 2005 07:05 PM
ADS -> AdsRegCallBack()
Posted: Wed Apr 26, 2006 03: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.
Posts: 1283
Joined: Fri Feb 10, 2006 02:34 PM
ADS -> AdsRegCallBack()
Posted: Thu Apr 27, 2006 07: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

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 ? :-)


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
HIX -> https://github.com/carles9000/hix
Posts: 840
Joined: Thu Oct 13, 2005 07:05 PM
ADS -> AdsRegCallBack()
Posted: Thu Apr 27, 2006 04: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.
Posts: 990
Joined: Thu Nov 17, 2005 05:49 PM
ADS -> AdsRegCallBack()
Posted: Sat Dec 23, 2006 05:49 PM
Rene;

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

Mi intenci贸n es usarla en algo asi:

	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.
Posts: 512
Joined: Mon Oct 17, 2005 10:38 AM
Re: ADS -> AdsRegCallBack()
Posted: Thu Aug 09, 2012 03: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.

Posts: 990
Joined: Thu Nov 17, 2005 05:49 PM
Re: ADS -> AdsRegCallBack()
Posted: Thu Aug 09, 2012 03:58 PM
It is working right now for me.

Here is the code snippet:

Code (fw): Select all Collapse
聽 聽 聽 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 (fw): Select all Collapse
*-------------------------------------------------------------------------------------------------------
#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.
Posts: 512
Joined: Mon Oct 17, 2005 10:38 AM
Re: ADS -&gt; AdsRegCallBack()
Posted: Thu Aug 09, 2012 04: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.

Posts: 512
Joined: Mon Oct 17, 2005 10:38 AM
Re: ADS -&gt; AdsRegCallBack()
Posted: Fri Aug 10, 2012 09: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<<<
Posts: 990
Joined: Thu Nov 17, 2005 05:49 PM
Re: ADS -&gt; AdsRegCallBack()
Posted: 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.

Posts: 811
Joined: Tue May 06, 2008 04:28 AM
Re: ADS -&gt; AdsRegCallBack()
Posted: Mon Oct 27, 2014 08: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
Posts: 990
Joined: Thu Nov 17, 2005 05:49 PM
Re: ADS -&gt; AdsRegCallBack()
Posted: Mon Oct 27, 2014 01: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.

Posts: 811
Joined: Tue May 06, 2008 04:28 AM
Re: ADS -&gt; AdsRegCallBack()
Posted: 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 (fw): Select all Collapse
    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
Posts: 990
Joined: Thu Nov 17, 2005 05:49 PM
Re: ADS -&gt; AdsRegCallBack()
Posted: Tue Oct 28, 2014 01:06 PM

Frances;

Nice job. I'll use your implementation.

Thank you.

Reinaldo.

Continue the discussion