Page 1 of 2

DCBROWSE autorefresh

Posted: Wed Jun 29, 2011 2:15 am
by Wolfgang Ciriack
Hi all,
i have a scoped DCBROWSE with autorefresh and a display of the amount of reccords (dc_keycount()) in the scope. Now i like to update the display of the amount of records, if the autorefresh take place (every 5 seconds). How can this be done, can someone give me a hint ?

Re: DCBROWSE autorefresh

Posted: Wed Jun 29, 2011 8:53 am
by rdonnay
Use the REFRESHBLOCK subclause of AUTOREFRESH.

[AUTOREFRESH <nRefreshInterval> [REFRESHBLOCK <bRefresh>]

In bRefresh block you would put your code to update the display.

Re: DCBROWSE autorefresh

Posted: Thu Jun 30, 2011 1:35 am
by Wolfgang Ciriack
Thanks Roger,
but when using this, i always get an error in the line 896:

Code: Select all

IF Empty(::refreshWhenBlock) .OR. Eval(::refreshWhenBlock)

Code: Select all

oError:args         :
          -> VALTYPE: L VALUE: N
          -> VALTYPE: U VALUE: NIL
oError:canDefault   : N
oError:canRetry     : N
oError:canSubstitute: J
oError:cargo        : NIL
oError:description  : Parameter hat falschen Typ
oError:filename     : 
oError:genCode      :          2
oError:operation    : <.F.>.or.<NIL>
oError:osCode       :          0
oError:severity     :          2
oError:subCode      :          3
oError:subSystem    : BASE
oError:thread       :          1
oError:tries        :          0



------------------------------------------------------------------------------
CALLSTACK:
------------------------------------------------------------------------------
Aufgerufen von DC_XBPBROWSE:HANDLEEVENT(896)

Re: DCBROWSE autorefresh

Posted: Thu Jun 30, 2011 6:19 am
by reganc
Wolfgang Ciriack wrote:Thanks Roger,
but when using this, i always get an error in the line 896:

Code: Select all

IF Empty(::refreshWhenBlock) .OR. Eval(::refreshWhenBlock)

Code: Select all

oError:args         :
          -> VALTYPE: L VALUE: N
          -> VALTYPE: U VALUE: NIL
oError:canDefault   : N
oError:canRetry     : N
oError:canSubstitute: J
oError:cargo        : NIL
oError:description  : Parameter hat falschen Typ
oError:filename     : 
oError:genCode      :          2
oError:operation    : <.F.>.or.<NIL>
oError:osCode       :          0
oError:severity     :          2
oError:subCode      :          3
oError:subSystem    : BASE
oError:thread       :          1
oError:tries        :          0

------------------------------------------------------------------------------
CALLSTACK:
------------------------------------------------------------------------------
Aufgerufen von DC_XBPBROWSE:HANDLEEVENT(896)
The docs say:

AUTOREFRESH <nTimer> is used to set a timer event that automatically
refreshes the browse window (when it is visible) every
<nTimer>/100 seconds. REFRESHBLOCK <bRefresh> is an optional
code block to evaluate rather than using the default :refresh()
method. WHEN <bRefreshWhen> is an option codeblock to evaluate
to cause the refresh to occur only when the codeblock returns a
.TRUE. value.

It looks like the when codeblock is not returning a TRUE or FALSE value. Are you using the AUTOREFRESH...WHEN clause? If not try giving it a codeblock that always returns TRUE.

Re: DCBROWSE autorefresh

Posted: Thu Jun 30, 2011 7:47 am
by rdonnay
Try this:

Code: Select all

.. REFRESHBLOCK {||myRefreshFunction()} WHEN {||.t.}

Re: DCBROWSE autorefresh

Posted: Thu Jun 30, 2011 10:17 am
by Wolfgang Ciriack
Hi Roger,
i have tried it with bWhenBlock and without, every time the same error. Here is my code:

Code: Select all

     @2.4,0.5 DCBROWSE oMainBrowse ;
       DATA cAlias ;
       SIZE min(br-20,iif(pInstMobile,116,114)), ho-5 ;
       CURSORMODE XBPBRW_CURSOR_ROW ;
       PRESENTATION aPresPar1 ;
       ITEMSELECTED {|| iif(userrights>=RIGHTS_E, StartAufBearb(), NIL), oMainBrowse:refreshAll(), SetAppFocus(oMainBrowse) } ;
       ITEMMARKED {|| bau->(dbseek(str(auf->baustelle,7),,1)), dc_getrefresh(GetList,,DCGETREFRESH_ID_INCLUDE,aRefId), oKfzBrowse:RefreshAll() } ;
       ID "IDBRW" ;
       FREEZELEFT iif(pInstMobile,{1,2,3,4,5,6,7},{1,2,3,4,5,6}) ;
       TABSTOP ;
       EVAL {|o| o:ItemRbDown:={|aMPos,aLC,oBr| dc_getrefresh(oPopupMenu), ActRbMenu(aMPos,aLC,oBr,oPopupMenu)} } ;
       AUTOREFRESH refrwert  REFRESHBLOCK {|| dc_getrefresh(oAnzRec) } WHEN {|| .T. }

*       AUTOREFRESH refrwert WHEN {|| .T.SetAppFocus()=oMainBrowse } REFRESHBLOCK {|| dc_getrefresh(oAnzRec) }

Re: DCBROWSE autorefresh

Posted: Thu Jun 30, 2011 5:40 pm
by rdonnay
This this:

Code: Select all

REFRESHBLOCK {|| dc_getrefresh(oAnzRec), .t. }

Re: DCBROWSE autorefresh

Posted: Thu Jun 30, 2011 9:41 pm
by Wolfgang Ciriack
Hi Roger,
i read the docs and thougt, only the WHEN codeblock must return a logical value. Thanks for the clarification.

Re: DCBROWSE autorefresh

Posted: Mon Jul 04, 2011 7:29 am
by rdonnay
I will have to correct that in the docs.

Re: DCBROWSE autorefresh

Posted: Tue Aug 30, 2011 2:46 pm
by gnewcomb
Unless I am mistaken, shouldn't lines 336 and 337 in _dcxbrow.prg

Code: Select all

::refreshWhenBlock := aArray[47]
::refreshBlock := aArray[48]
be changed to

Code: Select all

::refreshWhenBlock := aArray[48]
::refreshBlock := aArray[47]