How?: TBatchMove progress indication, cancel option. 
Author Message
 How?: TBatchMove progress indication, cancel option.

I am using TBatchMove to grab user-selected .DBF files
from a floppy, and convert them to .DB (P5) on hard disk.

I would like to let the operator cancel the transfer if
he wants to (e.g., having selected the wrong file). I would
also like to show a %-complete indication. Is there a
progress callback with boolean "keep-going" return value, or
equivalent, to do this? Seems like there ought to be...

TIA,

Regards,
Bengt Richter

It's been a week, and no response :-(
(Please excuse the re-post :-)



Sat, 17 Oct 1998 03:00:00 GMT  
 How?: TBatchMove progress indication, cancel option.

Quote:

>I am using TBatchMove to grab user-selected .DBF files
>from a floppy, and convert them to .DB (P5) on hard disk.
>I would like to let the operator cancel the transfer if
>he wants to (e.g., having selected the wrong file). I would
>also like to show a %-complete indication. Is there a
>progress callback with boolean "keep-going" return value, or
>equivalent, to do this? Seems like there ought to be...
>TIA,
>Regards,
>Bengt Richter
>It's been a week, and no response :-(

It's been >two weeks, and no response :-(
Quote:
>(Please excuse the re-post :-)



Sun, 01 Nov 1998 03:00:00 GMT  
 How?: TBatchMove progress indication, cancel option.

Quote:

>>I am using TBatchMove to grab user-selected .DBF files
>>from a floppy, and convert them to .DB (P5) on hard disk.
>>I would like to let the operator cancel the transfer if
>>he wants to (e.g., having selected the wrong file). I would
>>also like to show a %-complete indication. Is there a

Bengt,

I put a Gauge component and a Cancel button on a Form (FormGauge)
which I display during the data transfer. Setting
BatchMove.RecordCount to a nonzero value will make TBatchMove.Execute
transfer only the given number of records. I'm using the following
code to transfer records from a ASCII table to a Paradox table.

-------------------------
FormGauge.Gauge1.MinValue := 0;
FormGauge.Gauge1.MaxValue := TableSource.RecordCount;
FormGauge.Gauge1.Progress := 0;
FormGauge.Show;
FormGauge.BitBtn1.Caption := 'Cancel';

BatchMove1.RecordCount:=10;     {transfer 10 records a time}
nn=1;
try
  while (nn > 0) and not (TableSource) and not (CancelPressed) do
    begin
    {Move RecordCount records:}
    BatchMove1.Execute;
    ............
    nn := BatchMove1.MovedCount;
    FormGauge.Gauge1.Progress := FormGauge.Gauge1.Progress + nn;
    FormGauge.ProcCount.Refresh;
    FormGauge.Gauge1.Refresh;
    TableSource.MoveBy(nn);
    Application.ProcessMessages;
    end; {while}
except
  Application.HandleException(Sender);
end;
-------------------------

However, I have two problems left:
1) TableSource.RecordCount returns a value smaller than the correct
value,
2) As soon as I set BatchMove1.RecordCount to a nonzero value, the
first record of my ASCII table won't be transfered.

Maybe you won't have these problems with a DBF source table.
Hope this helps

           Thomas




Tue, 03 Nov 1998 03:00:00 GMT  
 How?: TBatchMove progress indication, cancel option.

Quote:


>Subject: Re: How?: TBatchMove progress indication, cancel option.
>Date: Fri, 17 May 1996 09:08:39 GMT

Another way to do this is to register a call back function with the BDE which
will get called as the BDE progresses - there's a good example of it
somewhere, but sorry, i just looked and can't seem to find it !

HTH

Boris Ingram, Cyborg Software

Compuserve : 100076, 3616
http://www.pcb.co.za/users/borising/cyborg.htm

Quote:

>>>I am using TBatchMove to grab user-selected .DBF files
>>>from a floppy, and convert them to .DB (P5) on hard disk.
>>>I would like to let the operator cancel the transfer if
>>>he wants to (e.g., having selected the wrong file). I would
>>>also like to show a %-complete indication. Is there a
>Bengt,
>I put a Gauge component and a Cancel button on a Form (FormGauge)
>which I display during the data transfer. Setting
>BatchMove.RecordCount to a nonzero value will make TBatchMove.Execute
>transfer only the given number of records. I'm using the following
>code to transfer records from a ASCII table to a Paradox table.
>-------------------------
>FormGauge.Gauge1.MinValue := 0;
>FormGauge.Gauge1.MaxValue := TableSource.RecordCount;
>FormGauge.Gauge1.Progress := 0;
>FormGauge.Show;
>FormGauge.BitBtn1.Caption := 'Cancel';
>BatchMove1.RecordCount:=10;     {transfer 10 records a time}
>nn=1;
>try
>  while (nn > 0) and not (TableSource) and not (CancelPressed) do
>    begin
>    {Move RecordCount records:}
>    BatchMove1.Execute;
>    ............
>    nn := BatchMove1.MovedCount;
>    FormGauge.Gauge1.Progress := FormGauge.Gauge1.Progress + nn;
>    FormGauge.ProcCount.Refresh;
>    FormGauge.Gauge1.Refresh;
>    TableSource.MoveBy(nn);
>    Application.ProcessMessages;
>    end; {while}
>except
>  Application.HandleException(Sender);
>end;
>-------------------------
>However, I have two problems left:
>1) TableSource.RecordCount returns a value smaller than the correct
>value,
>2) As soon as I set BatchMove1.RecordCount to a nonzero value, the
>first record of my ASCII table won't be transfered.
>Maybe you won't have these problems with a DBF source table.
>Hope this helps
>           Thomas




Wed, 04 Nov 1998 03:00:00 GMT  
 How?: TBatchMove progress indication, cancel option.


:
: >I am using TBatchMove to grab user-selected .DBF files
: >from a floppy, and convert them to .DB (P5) on hard disk.
:
: >I would like to let the operator cancel the transfer if
: >he wants to (e.g., having selected the wrong file). I would
: >also like to show a %-complete indication. Is there a
: >progress callback with boolean "keep-going" return value, or
: >equivalent, to do this? Seems like there ought to be...

Hi,

here is small example how to use BDE's RegisterCallBack function with TQuery component. It should work with TBatchMove also (never tried).

Sorry, if it contains typos or some other errors - I do not have Delphi here to check it out.

There is also other example available from
http://sunsite.icm.edu.pl/~robert/delphi/ftp/freeware/callback.zip

hope it helps,
Tanel

unit cbqbe;

interface

uses
  DsgnIntf, SysUtils, Classes,
  DB, DBTables, dbiTypes, dbiProcs;

type

  { Note that, if iPercent < 0, then useful information is in sMessage
    Return False, if you want to cancel process
  }
  TCallBackEvent = function( iPercent: Integer; sMessage: String): Boolean of Object;

  TCallBackQuery = class( TQuery )
  protected
    FOnCallBack: TCallBackEvent;
    FCallBackBuffer: CBPROGRESSDesc;

    procedure RegisterCB;
    procedure UnRegisterCB;
    function CreateHandle: HDBICur; override;
  public
    destructor Destroy; override;
  published
    property OnCallBack: TCallBackEvent read FOnCallBack write FOnCallBack;
  end;

implementation

{
  This is callback function
  iClientData contains object's self
  CbInfo contains process information

Quote:
}

function CallBackFn( ecbType:CBType; iClientData:Longint; var CbInfo: Pointer): CBRType; export;
var
  prInf: CBPROGRESSDesc;
begin
  Result := cbrCONTINUE;  { By default continue }
  if (ecbType = cbGenPROGRESS) and (iClientData <> 0)  then begin

    if Assigned( TCallBackQuery( iClientData ).FOnCallBack ) then
      if not TCallBackQuery( iClientData ).FOnCallBack( prInf.iPercentDone, strpas(prInf.szmsg) ) then
        Result := cbrABORT;
 end;
end;

{ UnRegister callback fn. I do not know, if it is the right place to do this }
destructor TCallBackQuery.Destroy;
  UnRegisterCB;
  inherited Destroy;
end;

function TCallBackQuery.CreateHandle: HDBICur;
begin
  RegisterCB;
  Result := inherited CreateHandle;
end;

{ This procedure will Register callback function }
procedure TCallBackQuery.RegisterCB;
begin
  DbiRegisterCallBack( Handle, cbGenPROGRESS, LongInt( Self ),

end;

procedure TCallBackQuery.UnRegisterCB;
begin
  DbiRegisterCallBack( Handle, cbGenPROGRESS, LongInt( Self ),

end;

end.



Thu, 05 Nov 1998 03:00:00 GMT  
 How?: TBatchMove progress indication, cancel option.

Quote:



>>Subject: Re: How?: TBatchMove progress indication, cancel option.
>>Date: Fri, 17 May 1996 09:08:39 GMT
>Another way to do this is to register a call back function with the BDE which
>will get called as the BDE progresses - there's a good example of it
>somewhere, but sorry, i just looked and can't seem to find it !
>HTH

If this will let me initiate the full transfer, and monitor/cancel it
in the callback, it will be what I was looking for.

Thanks for the lead.

Regards,
Bengt Richter



Sat, 07 Nov 1998 03:00:00 GMT  
 How?: TBatchMove progress indication, cancel option.

Quote:


>>>I am using TBatchMove to grab user-selected .DBF files
>>>from a floppy, and convert them to .DB (P5) on hard disk.
>>>I would like to let the operator cancel the transfer if
>>>he wants to (e.g., having selected the wrong file). I would
>>>also like to show a %-complete indication. Is there a
>Bengt,
>I put a Gauge component and a Cancel button on a Form (FormGauge)
>which I display during the data transfer. Setting
>BatchMove.RecordCount to a nonzero value will make TBatchMove.Execute
>transfer only the given number of records. I'm using the following
>code to transfer records from a ASCII table to a Paradox table.
>-------------------------
>FormGauge.Gauge1.MinValue := 0;
>FormGauge.Gauge1.MaxValue := TableSource.RecordCount;
>FormGauge.Gauge1.Progress := 0;
>FormGauge.Show;
>FormGauge.BitBtn1.Caption := 'Cancel';
>BatchMove1.RecordCount:=10;     {transfer 10 records a time}
>nn=1;
>try
>  while (nn > 0) and not (TableSource) and not (CancelPressed) do
>    begin
>    {Move RecordCount records:}
>    BatchMove1.Execute;
>    ............
>    nn := BatchMove1.MovedCount;
>    FormGauge.Gauge1.Progress := FormGauge.Gauge1.Progress + nn;
>    FormGauge.ProcCount.Refresh;
>    FormGauge.Gauge1.Refresh;
>    TableSource.MoveBy(nn);
>    Application.ProcessMessages;
>    end; {while}
>except
>  Application.HandleException(Sender);
>end;
>-------------------------
>However, I have two problems left:
>1) TableSource.RecordCount returns a value smaller than the correct
>value,
>2) As soon as I set BatchMove1.RecordCount to a nonzero value, the
>first record of my ASCII table won't be transfered.
>Maybe you won't have these problems with a DBF source table.
>Hope this helps

Thanks for taking time for me.

I will try something along those lines if I can't find or
get working the BDE callback Boris Ingram mentions. Perhaps
that method can help you with the remaining two problems
as well. Now that I have some new leads I should be getting
back and updating my program, probably in the coming week.
If I get/find/figure out an effective callback solution,
I'll post a snippet.

Regards,
Bengt



Sat, 07 Nov 1998 03:00:00 GMT  
 How?: TBatchMove progress indication, cancel option.

Quote:

>Hi,
>here is small example how to use BDE's RegisterCallBack function with TQuery component. It should work with TBatchMove also (never tried).
>Sorry, if it contains typos or some other errors - I do not have Delphi here to check it out.
>There is also other example available from
>http://sunsite.icm.edu.pl/~robert/delphi/ftp/freeware/callback.zip

Thank you! I will try it.
Regards,
Bengt Richter


Sat, 07 Nov 1998 03:00:00 GMT  
 How?: TBatchMove progress indication, cancel option.

Quote:
>>Bengt replied
>>However, I have two problems left:
>>1) TableSource.RecordCount returns a value smaller than the correct
>>value,

Try TableSource.Last before using TableSouce.RecordCount
If you are using ODBC keyset driven cursors (Dynasets) will not build
the result set in full, resulting in RecordCount returning a lower
value than the actual.

Regarding your second problem, I hope someone else would help.

kind regards
R.Venkatesh



Wed, 11 Nov 1998 03:00:00 GMT  
 
 [ 9 post ] 

 Relevant Pages 

1. How?: TBatchMove progress indication, cancel option.

2. Multiple users: indication for data changes

3. DBGrid1.Options.Editing toggle by code?

4. Date control with null option

5. I see no Advanced Options button using Reportsmith - ??

6. Table.Locate options for multiple field searches

7. Delphi vs. the other options

8. Options for GUI development using FPC

9. DeskTop, SQL, or Other Option??

10. Problems with the requested option of Paradox Tables

11. Compiler options to specify *.exe file name?

12. Trace option in BP 7.0 on NT

 

 
Powered by phpBB® Forum Software