oReport meter/ progressbar

oReport meter/ progressbar

Postby Otto » Tue Jul 28, 2009 8:38 am

Is it possible to have a progressbar or a meter into oReport class.

Thanks in advance
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6364
Joined: Fri Oct 07, 2005 7:07 pm

Re: oReport meter/ progressbar

Postby Marcelo Via Giglio » Tue Jul 28, 2009 12:58 pm

Hi Otto,

there is a dialog with message of page creation, you can use this dialog to put a progressbar, but the problem is to know how many pages has the report
to set the progressbar, you need to calculate this previus to send the report maybe an estimate or generate the report without preview and generate again to obtain the total pages, this is the same problem if you need to put page number like "pagen of totalpage" in this case I write this information at the end of report directly to the EMF files.

regards

Marcelo
Marcelo Via Giglio
 
Posts: 1071
Joined: Fri Oct 07, 2005 3:33 pm
Location: Cochabamba - Bolivia

Re: oReport meter/ progressbar

Postby nageswaragunupudi » Wed Jul 29, 2009 1:26 am

You can't know the total pages that will be printed but you know the total lines to be printed.

You can implement progress bar on the basis of number of lines printed in comparison with the total lines to be printed. The point is how do we get a callback to our program whenever a line is printed.

We supply a bSkip block the Report class. For DBF, report class has a default bSkip block. But we can supply our own bSkip block. It is in this bSkip block you provide, you can capture the record number being printed and use it in your progress bar.

But I do not find any need for progress bar for reports because the preview generation shows the user some kind of progress and that is adequate in most circumstances.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10690
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: oReport meter/ progressbar

Postby Otto » Wed Jul 29, 2009 6:52 am

Hello,
Maybe I make an error defining the report- but till the first msgwait from oReport appears 23 sec. pass.
Till now I always loaded the records I wanted to print into a temp dbf and then started the oReport printing the temp-dbf.
There a meter is easy to implement. In this case the msgwait appears quick.

But I thought I could do it without this extra code.
This is how I use oReport.

Best regards,
Otto

Code: Select all  Expand view  RUN


function rg_kontroll_druck(oStam)
   local oReport,oFont1, oFont2, oFont3, oPen1, oline,cTITLE:="Rechnungs-Zusammenstellung vom"
   local anfang  := date()-1
   local ende    := date()-1
   local oDlg
   local ok      := .f.
*----------------------------------------------------------

   DEFINE DIALOG oDlg RESOURCE "Vonbis" TITLE "Rechnungszusammenstellung"

   REDEFINE GET  anfang ID 101 of oDlg picture("@D") SPINNER
   REDEFINE GET  ende   ID 102 of oDlg picture("@D") SPINNER
   REDEFINE BUTTONBMP ID 2 OF oDlg ;
      ACTION oDlg:END()   CANCEL    ;
      BITMAP ".\bitmaps\Delete.bmp"   TEXTRIGHT

   REDEFINE BUTTON      ID 1   OF oDlg ACTION (OK:=.T.,oDlg:END())
   ACTIVATE DIALOG oDlg CENTERED

   IF OK = .T.

      DEFINE PEN oPen1 WIDTH 0.5
      DEFINE FONT oFont1 NAME "ARIAL" SIZE 0,-9
      DEFINE FONT oFont2 NAME "ARIAL" SIZE 0,-8
      DEFINE FONT oFont3 NAME "ARIAL" SIZE 0,-14 BOLD

      select umsatz
      set order to tag u_renr
      Go Top

      REPORT oReport TITLE " ",cTITLE+"   "+ dtoc(anfang)+" - "+dtoc(ende)," "  LEFT ;
            FONT   oFont1,;
            oFont2,;
            oFont3 ;
            PEN oPen1;
            HEADER Setup():LizenzNehmer()," ", ALLTRIM("Erstellt: " + dtoc(date())+ " - "+time()) RIGHT;
            FOOTER "Seite " + Str(oReport:nPage,3) RIGHT PREVIEW

         COLUMN TITLE "Artnum"       DATA    umsatz->artnum                  SIZE 8   FONT 2
         COLUMN TITLE "Bezeichnung"  DATA    umsatz->bezeichnun              SIZE 26
         COLUMN TITLE "an"           DATA    umsatz->datum1                  SIZE 8   FONT 2
         COLUMN TITLE "ab"           DATA    umsatz->datum2                  SIZE 8   FONT 2

         COLUMN TITLE "Menge"        DATA    umsatz->menge                   SIZE 5  PICTURE "999,999,999.9"
         COLUMN TITLE "Preis"        DATA    umsatz->preis                   SIZE 6  PICTURE "999,999,999.99" FONT 2
         COLUMN TITLE "Wert"         DATA    umsatz->wert                                 TOTAL        SIZE 8  PICTURE "999,999,999.99"

         COLUMN TITLE "Anzhg"        DATA    iif(umsatz->Anzhg<>0,  umsatz->Anzhg,"")     TOTAL        SIZE 8  PICTURE "999,999,999.99"
         COLUMN TITLE "Barzhg"       DATA    iif(umsatz->Barzhg<>0, umsatz->Barzhg,"")    TOTAL        SIZE 8  PICTURE "999,999,999.99"
         COLUMN TITLE "Karte"        DATA    iif(umsatz->Karte<>0,  umsatz->Karte,"")     TOTAL        SIZE 8  PICTURE "999,999,999.99"
         COLUMN TITLE "Scheck"       DATA    iif(umsatz->Scheck<>0, umsatz->Scheck,"")    TOTAL        SIZE 8  PICTURE "999,999,999.99"
         COLUMN TITLE "Kredit"       DATA    iif(umsatz->Kredit<>0, umsatz->Kredit,"")    TOTAL        SIZE 8  PICTURE "999,999,999.99"

         GROUP ON umsatz->renr HEADER xPADR(ALLTRIM(str(umsatz->renr)),85)+xPADr(ALLTRIM(umsatz->name),195)+dtoc(umsatz->datum)  FOOTER "Summe" FONT 3

      END REPORT
     
      oReport:CellView()

      oLine:= oReport:oTitle
      oLine:aFont[2] := {|| 3}

      ACTIVATE REPORT oReport ;
         FOR umsatz->datum >=anfang .AND. umsatz->datum <= ende ;
            ON STARTGROUP oReport:NewLine()

         oPen1:End()
         oFont1:End()
         oFont2:End()
         oFont3:End()


      endif
     
return nil
//----------------------------------------------------------------------------//


 
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6364
Joined: Fri Oct 07, 2005 7:07 pm

Re: oReport meter/ progressbar

Postby James Bott » Wed Jul 29, 2009 10:38 pm

Otto,

It looks like the delay is because you are using a filter. Try it without the filter and see how fast it is (just for a test). If that solves the speed issue, then you could build a modified index and use scopes.

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: oReport meter/ progressbar

Postby nageswaragunupudi » Thu Jul 30, 2009 3:07 am

I agree with Mr James

Also an out off topic suggestion
Instead of
iif(umsatz->Anzhg<>0, umsatz->Anzhg,"") PICTURE "999,999,999.99"

it may be simpler to write
Code: Select all  Expand view  RUN
umsatz->Anzhg PICTURE "@Z 999,999,999.99"
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10690
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: oReport meter/ progressbar

Postby Otto » Thu Jul 30, 2009 6:28 am

Hello James,
thank you for the suggestion. I changed the code and use now a temporary index instead of the filter.
Code: Select all  Expand view  RUN
select umsatz
      index on umsatz->datum  TAG TEMPDAT3 TO TEMP TEMPORARY FOR (umsatz->datum >= (anfang) .AND. umsatz->datum <= (ende))
   
Now the Report msgwait shows within 2 sec.

Helo Mr. Rao,
Thank you for the information. Good to know that. It makes the code much easier to read.
Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6364
Joined: Fri Oct 07, 2005 7:07 pm

Re: oReport meter/ progressbar

Postby James Bott » Thu Jul 30, 2009 6:55 am

Otto,

>I changed the code and use now a temporary index instead of the filter.

Still a temp index will cause a lag since it needs to read the whole DBF. Why not use scopes? You may need to build a new permanant index including the date field at the start of the index. Then set the scope to the beginning and ending date. This will be very fast and you don't need a temp index.

index on dtos( datum ) + renr

Then set the scopes.

umsatz->(ordScope(0, dtos(anfang) ) // set top scope
umsatz->(ordScope(1, dtos(ende) ) // set bottom scope
umsatz->(dbgotop())


James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: oReport meter/ progressbar

Postby James Bott » Thu Jul 30, 2009 7:36 am

Otto,

After thinking about it, the scopes in my previous message aren't going to work since you need to group by renr. It is late here and I am not thinking clearly. I will get back to you in the morning.

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: oReport meter/ progressbar

Postby Otto » Thu Jul 30, 2009 7:43 am

Hello James,
Thank you. I tried with your code and it seems that all works very well.
Now there is no speed problem anymore.
Best regards,
Otto

Code: Select all  Expand view  RUN

   index on dtos(field->datum)+str(field->renr)         tag u_datrg //12
...  



   select umsatz
     //index on umsatz->datum  TAG TEMPDAT3 TO TEMP TEMPORARY FOR (umsatz->datum >= (anfang) .AND. umsatz->datum <= (ende))
 
  set order to tag u_datrg
umsatz->(ordScope(0, dtos(anfang) ))  // set top scope
umsatz->(ordScope(1, dtos(ende) ) )   // set bottom scope
umsatz->(dbgotop())
 
 
 

 
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6364
Joined: Fri Oct 07, 2005 7:07 pm

Re: oReport meter/ progressbar

Postby James Bott » Thu Jul 30, 2009 1:55 pm

Otto,

Glad to hear it. But, don't you need to group by the field "renr" also? If so, then it gets more complicated. I came up with an idea, but it will take some testing to figure out the details.

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: oReport meter/ progressbar

Postby Marcelo Via Giglio » Thu Jul 30, 2009 2:35 pm

Otto,

for this topic I am happy using ADSRDD, because you can mix SQL with traditional table navigation,
in your case a simple select <colums> from <table> where <condition> order by <order> is the solution
you can try

regards

Marcelo
Marcelo Via Giglio
 
Posts: 1071
Joined: Fri Oct 07, 2005 3:33 pm
Location: Cochabamba - Bolivia

Re: oReport meter/ progressbar

Postby Otto » Thu Jul 30, 2009 2:51 pm

Hello james,
the report is grouped by the field - and displayed ok.
Best regards,
Otto

Hello Marcelo,
I will test ADS when I have more time.
Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6364
Joined: Fri Oct 07, 2005 7:07 pm

Re: oReport meter/ progressbar

Postby Marcelo Via Giglio » Wed Aug 05, 2009 6:08 pm

Otto,

I found a simple sample that I made some years ago...

copy this (sql.prg, sql.rc) into fw sample folder, uncomment the lines to link ace32.lib and rddads.lib in the buildx.bat file and compile it.

to probe select CDX file type, connect to the currect directory .\ when you press the CONETAR button, the square must be change to green, then
put select * from customer into Consulta SQL text area and press Ejecutar

I hope this can be a sample, you can join more than one dbf file from the current directory, this can be easily changed to work with data dictionay and client server too.

saludos

Marcelo

Code: Select all  Expand view  RUN
#include "fivewin.ch"   

REQUEST ADS

function main()
LOCAL oDlg, consulta := SPACE(400), oLbx, path := SPACE(80),;
      connect, tipo := "CDX", hconn

   RddRegister("ads",1)
   RddSetDefault("Ads")
   AdsSetServerType ( 1 ) // local
   AdsSetFileType(3)

   SET DELETED ON
   adsRightsCheck( .F. )

   DEFINE DIALOG oDlg RESOURCE "consulta"

      REDEFINE COMBOBOX tipo ID 108 ITEMS {"NTX","CDX","ADT"} OF oDlg ;
                        ON CHANGE AdsSetFileType( IF( tipo == "NTX", 1,              ;
                                                      IF( tipo == "CDX", 2, 3 ) ) )
          REDEFINE GET path ID 102 OF oDlg

      REDEFINE BUTTON ID 103 OF oDlg  ACTION ( AdsDisconnect( hconn ),;
                                               IF ( AdsConnect60( path , 1,"ADSSYS",,@hconn), ;
                                connect:setcolor(CLR_GREEN, CLR_GREEN),;
                                                    connect:setcolor(CLR_HRED, CLR_HRED ) ;
                              ),;
                                               connect:refresh() ;
                          )
      REDEFINE SAY connect PROMPT "  " ID 110 OF oDlg COLOR CLR_HRED, CLR_HRED
          REDEFINE GET consulta ID 104 OF oDlg
      REDEFINE BUTTON ID 106 OF oDlg ACTION  resultado( consulta )
                               
      REDEFINE BUTTON ID 107 OF oDlg ACTION oDlg:end()

   ACTIVATE DIALOG oDlg

   dbcloseall()

   AdsDisconnect( hconn )

return  nil

FUNCTION resultado( consulta )
    LOCAL oDlg, oLbx,e

   
    ADSCreateSQLStatement("SQLarea",2)
   
    IF ADSExecuteSQLDirect( consulta )
       TRY
         
         DEFINE DIALOG oDlg RESOURCE "resultado"

      REDEFINE LISTBOX oLbx FIELDS ALIAS "SQLarea" ID 101 OF oDlg
          REDEFINE SAY PROMPT "RESULTADO : " + ALLTRIM( STR ( SQLarea -> ( LASTREC() ) ) )  ID 200 OF oDlg COLOR CLR_BLUE
      REDEFINE BUTTON ID 102 OF oDlg ACTION oDlg:end()
      REDEFINE BUTTON ID 103 OF oDlg ACTION oLbx:report()

         ACTIVATE DIALOG oDlg
     sqlarea -> ( DBCLOSEAREA() )

       CATCH e
         ? "COMANDO EJECUTADO"
       END
    ELSE
        MSGINFO("Error en la ejecución de la consulta")
    sqlarea -> ( DBCLOSEAREA() )
    ENDIF
       
RETURN NIL


Code: Select all  Expand view  RUN
CONSULTA DIALOG 29, 88, 436, 141
STYLE DS_MODALFRAME | 0x4L | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "ADS - SQL"
FONT 8, "MS Sans Serif"
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
{
 CONTROL "", 108, "COMBOBOX", CBS_DROPDOWNLIST | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 40, 11, 49, 43
 CONTROL "", 102, "EDIT", ES_LEFT | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 136, 11, 219, 12
 CONTROL "conectar", 103, "BUTTON", BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 360, 11, 50, 14
 CONTROL "", 104, "EDIT", ES_LEFT | ES_MULTILINE | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 13, 40, 414, 57
 CONTROL "Ejecutar", 106, "BUTTON", BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 376, 101, 50, 14
 CONTROL "Salir", 107, "BUTTON", BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 376, 124, 50, 14
 CONTROL "Local Path", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE | WS_GROUP, 94, 13, 40, 8
 CONTROL "Consulta SQL", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE | WS_GROUP, 13, 29, 60, 8
 CONTROL "", 110, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE | WS_GROUP, 414, 11, 12, 12
 CONTROL "Tipo", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE | WS_GROUP, 13, 12, 22, 8
 CONTROL "", -1, "BUTTON", BS_GROUPBOX | WS_CHILD | WS_VISIBLE, 5, 0, 428, 120
}


RESULTADO DIALOG 8, 27, 400, 188
STYLE DS_SYSMODAL | 0x4L | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
CAPTION "RESULTADO CONSULTA"
FONT 8, "MS Sans Serif"
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
{
 CONTROL "", 101, "TWBrowse", 0 | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL | WS_HSCROLL | WS_TABSTOP, 5, 7, 390, 159
 CONTROL "Salir", 102, "BUTTON", BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 345, 171, 50, 14
 CONTROL "RESULTADO", 200, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE | WS_GROUP, 6, 174, 93, 8
 CONTROL "Reporte", 103, "BUTTON", BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 294, 171, 50, 14
}

 
Marcelo Via Giglio
 
Posts: 1071
Joined: Fri Oct 07, 2005 3:33 pm
Location: Cochabamba - Bolivia


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 17 guests