Page 1 of 1

Bug in TSay

Posted: Sun Dec 24, 2006 10:58 pm
by Enrico Maria Giordano
The following sample shows the problem:

Code: Select all

#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oDlg, oSay

    LOCAL n := 0

    DEFINE DIALOG oDlg

    @ 1, 1 SAY oSay PROMPT "Counter: " + LTRIM( STR( n ) );
           SIZE 200, 15

    @ 2, 1 BUTTON "Start";
           ACTION COUNTER( oSay, @n )

    ACTIVATE DIALOG oDlg;
             CENTER

    RETURN NIL


STATIC FUNCTION COUNTER( oSay, n )

    LOCAL i

    FOR i = 1 TO 100
        n++
        oSay:Refresh()
        SYSWAIT( 0.01 )
    NEXT

    TONE( 400, 1 )

    RETURN NIL
It should count from 1 to 100 when the button is pressed. Instead the label shows 1 and is not refreshed anymore.

The cause seems to be the statement

Code: Select all

::VarPut( ::cCaption )
added in the latest TSay class.

EMG

Re: Bug in TSay

Posted: Sun Dec 24, 2006 11:04 pm
by Enrico Maria Giordano
Even during reports generation the counter is not updated anymore.

EMG

Posted: Mon Dec 25, 2006 12:57 am
by Antonio Linares
Enrico,

We may remove ::VarPut( ::cCaption ) from Class TSay Method SetText(), but then preview page number is wrongly shown.

We need to find a way to fix the preview page number.

Posted: Mon Dec 25, 2006 1:01 am
by Antonio Linares
Ok, the solution seems to replace in source\classes\rpreview.prg all oPage:SetText(...) into oPage:VarPut(...)

Posted: Mon Dec 25, 2006 1:13 am
by Antonio Linares
This looks as a right fix for rpreview.prg:

Code: Select all

     if ! IsAppThemed()
        oPage:VarPut( TXT_PAGENUM + LTrim( Str( nPage, 4, 0 ) ) + " / " + ;
                                    LTrim( Str( Len( aFiles ) ) ) )
     else                               
        oPage:SetText( TXT_PAGENUM + LTrim( Str( nPage, 4, 0 ) ) + " / " + ;
                                     LTrim( Str( Len( aFiles ) ) ) )
     endif                               
In all places where oPage:SetText() was called.

Posted: Mon Dec 25, 2006 9:14 am
by Enrico Maria Giordano
Or just remove

Code: Select all

oBar:Refresh()
EMG

Posted: Mon Dec 25, 2006 9:23 am
by Antonio Linares
Enrico,

But if a window is moved over the preview, then it will have the same effect as calling :Refresh()

Posted: Mon Dec 25, 2006 9:29 am
by Enrico Maria Giordano
Antonio Linares wrote:Enrico,

But if a window is moved over the preview, then it will have the same effect as calling :Refresh()
You are right. Instead try to replace

Code: Select all

@ 7, 370 SAY oPAGE PROMPT cPageNum ;
with

Code: Select all

@ 7, 370 SAY oPAGE PROMPT TXT_PAGENUM+ltrim(str(nPage,4,0)) + " / " + ltrim(str(len(aFiles))) ;
EMG

Posted: Mon Dec 25, 2006 10:54 am
by Antonio Linares
Enrico,

Yes, thats a better solution. Thanks :-)