Problem with tmeter

Problem with tmeter

Postby Silvio.Falconi » Mon Nov 14, 2022 10:05 am

I have a Meter on a dialog

@ 55, 40 METER oProgress VAR nActual SIZE 120,20 PIXEL OF oDlgAgg ;
COLOR 0x60ff0000, CLR_BLACK ;
BARCOLOR 0x6000ff00, CLR_WHITE ;
TOTAL nTotal FONT oFont BORDER CLR_BLACK ; // CIRCULAR INNERDIA { |n| 0.2 + ( 0.6 * n ) } ;
FILLCOLOR { |n| NARGB( 210 - ( n * 200 ), CLR_BLACK ) } ;
UPDATE


I have to perform 3 procedures
1) download of the history in zip format and unpacking in txt
2) save storico.txt into storico.dbf
3) conversion from storico.dbf to lotto.dbf

for the procedure 2 and 3 I use the same meter (oProgress)

for procedure 1

local nPos := 1
local bprogress := { || (oProgress:Set( npos++ ),; //oProgress:SetPos( npos++ ),;
oSay[3]:SetText(ltrim(str(npos))),;
oSay[3]:refresh(),;
SysRefresh() ) }

...
oProgress:ntotal:= len(aData)
nMeter:=0
oProgress:set(nMeter)

oStorico:FW_ArrayToDbf( anew,,bprogress )


nothing happens the meter is stopped at 0%


for procedure 2
local nPos := 1
nTotaleStorico:=oStorico:RecCount()
nMeter:=0
oProgress:set(nMeter)
oProgress:ntotal:= len(nTotaleStorico) //this make me error

Do while .not. oStorico:eof()
.....



oStorico:skip()
oProgress:Set( npos++ )
ENDDO

nothing happens the meter is stopped at 1%

however both the download from the site and the unpacking, both the conversion from the file "storico.txt" into "storico.dbf" and both the conversion is performed correctly.

only that the meter is stopped

I cannot publish the whole procedure because it is complex
I can only publish a function which then corrected Nageswarao to archive only the records greater than a certain date from storico.txt into storico.dbf


Code: Select all  Expand view

Function test()
local  oDlgAgg
    local  nBottom   := 24
    local  nRight    := 51.9
    local  nWidth :=  Max( nRight * DLG_CHARPIX_W, 180 )
    local  nHeight := nBottom * DLG_CHARPIX_H
    local oBtnok,oBtnCan,oProgress
     local nActual := 0, nTotal := 50000

DEFINE DIALOG oDlgAgg SIZE nWidth, nHeight   TRANSPARENT ;
 TITLE ctitle       ;
 STYLE nOr( DS_MODALFRAME, WS_POPUP, WS_CAPTION,  4 )


 @  55, 40 METER oProgress VAR nActual  SIZE 120,20 PIXEL OF oDlgAgg  ;
      COLOR    0x60ff0000, CLR_BLACK ;
      BARCOLOR 0x6000ff00, CLR_WHITE ;
      TOTAL nTotal FONT oFont BORDER CLR_BLACK ;  //  CIRCULAR INNERDIA { |n| 0.2 + ( 0.6 * n ) } ;
      FILLCOLOR { |n| NARGB( 210 - ( n * 200 ), CLR_BLACK ) } ;
      UPDATE


    @ 163, 10 BTNBMP  oBtnok PROMPT "&Avvia la procedura" OF oDlgAgg SIZE 125,12 FLAT PIXEL  ACTION  Conversione_storico(oProgress,oSay)  NOROUND
    @ 163, 145 BTNBMP oBtnCan PROMPT "&Annulla" OF oDlgAgg SIZE 45,12 FLAT PIXEL  ACTION ( oDlgAgg:end( IDCANCEL ) ) NOROUND


    ACTIVATE DIALOG oDlgAgg CENTER
    RETURN NIL
//--------------------------------------------------------------------------------------------------------------------------------------------------------//

function Conversione_storico(oProgress,oSay)

   local cText, aData, aNew, dMaxDate
   local oLotto,oStorico
   local cdbfPath:=".\data\"
   local cStoricoPath:="
.\storico\"

    local  nPos     := 1
    local  bprogress  := { || (oProgress:Set( npos++ ),; //oProgress:SetPos( npos++ ),;
                                 oSay[3]:SetText(ltrim(str(npos))),;
                                   oSay[3]:refresh(),;
                                  SysRefresh() ) }


   cText    := HB_MEMOREAD( cStoricoPath+"
storico.txt" )
   cText    := FW_ALLTRIM( cText )
   cText    := StrTran( cText, CRLF, Chr( 10 ) )

   aData    := HB_ATokens( cText, Chr( 10 ) )


   AEval( aData, { |c,i| aData[ i ] := HB_ATokens( c, Chr( 9 ) ) } )
   AEval( aData, { |a,i| a[ 1 ] := uCharToVal( a[ 1 ], "
D" ) } )

   oLotto:= TDatabase():Open( , cdbfPath+"
LOTTO", "DBFCDX", .T. )
   oLotto:setorder(1)  //data
   oLotto:GoBottom()

   dMaxDate := oLotto:DATA

 //  XBROWSER oLotto SHOW RECID   TITLE "
TRACE LOTTO "+ dtos(dMaxDate)
   oLotto:close()

    //creazione archivio storico
    Create_StoricoDb(cdbfPath)
       oStorico:= TDatabase():Open( , cdbfPath+"
Storico", "DBFCDX", .T. )

   // XBROWSER oStorico SHOW RECID  TITLE "
TRACE STORICO"

    Ut_ResetMeter( oProgress, npos )
   oProgress:ntotal:= len(aData)

   aNew     := {}
   AEval( aData, { |a| If( a[ 1 ] > dMaxDate, AAdd( aNew, a ), ) } )
   oStorico:FW_ArrayToDbf( anew,,bprogress )


  //  XBROWSER oStorico SHOW RECID  TITLE "
STORICO"
    oStorico:close()

   CLOSE DATA

  RETURN NIL
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7033
Joined: Thu Oct 18, 2012 7:17 pm

Re: Problem with tmeter

Postby Antonio Linares » Mon Nov 14, 2022 10:13 am

Dear Silvio,

Better use a progress bar as it uses Windows animation, themes, etc

Please review samples\win32.prg
regards, saludos

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

Re: Problem with tmeter

Postby Silvio.Falconi » Mon Nov 14, 2022 11:06 am

Antonio Linares wrote:Dear Silvio,

Better use a progress bar as it uses Windows animation, themes, etc

Please review samples\win32.prg


Antonio perhaps I resolved

I change only

oProgress:nTotal:=len(adata)

with

oProgress:settotal(len(adata))

and run ok I not Know why

Image
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7033
Joined: Thu Oct 18, 2012 7:17 pm

Re: Problem with tmeter

Postby Antonio Linares » Mon Nov 14, 2022 11:10 am

great!

well done :-)
regards, saludos

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


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 29 guests