FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Bug in TGraph
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Bug in TGraph
Posted: Mon Sep 26, 2016 01:09 PM
This is a sample:

Code (fw): Select all Collapse
#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oWnd

    DEFINE WINDOW oWnd

    ACTIVATE WINDOW oWnd;
             ON INIT TEST()

    RETURN NIL


STATIC FUNCTION TEST()

    LOCAL oPrn, oGraph

    PRNLANDSCAPE()

    PRINT oPrn NAME "Test" PREVIEW
        PAGE
            oGraph = TGraph():New()

            oGraph:lXGrid = .T.
            oGraph:lYGrid = .T.

            oGraph:lDotted  = .F.
            oGraph:lTitle   = .T.
            oGraph:lLegends = .F.

            oGraph:cTitle = "TEST"

            oGraph:nBarSep = 100

            oGraph:lxVal = .T.
            oGraph:lViewVal = .T.

            oGraph:cTitX = "TESTX"
            oGraph:cTitY = "TESTY"

            oGraph:aSeries = { { "", RGB( 109, 177, 124 ), 1, .F. } }

            oGraph:aYVals = {}
            oGraph:aData = { {} }

            AADD( oGraph:aYVals, "2016" )
            AADD( oGraph:aData[ 1 ], 100 )

            oGraph:Print( oPrn, 5 * oPrn:nVertRes() / 66, 5 * oPrn:nHorzRes() / 80, 70 * oPrn:nHorzRes() / 80, 56 * oPrn:nVertRes() / 66 )
        ENDPAGE
    ENDPRINT

    PRNPORTRAIT()

    RETURN NIL


I get the following error:

Code (fw): Select all Collapse
Application
===========
   Path and name: E:\FWXHARB\PEPPE.EXE (32 bits)
   Size: 3,106,816 bytes
   Compiler version: xHarbour 1.2.3 Intl. (SimpLex) (Build 20160815)
   FiveWin  Version: FWHX 16.06
   Windows version: 6.2, Build 9200 

   Time from start: 0 hours 0 mins 0 secs 
   Error occurred at: 09/26/16, 15:05:55
   Error description: Error BASE/1132  Bound error: array access
   Args:
     [   1] = A   { ... } length: 1
     [   2] = N   2

Stack Calls
===========
   Called from: .\source\classes\TGRAPH.PRG => TGRAPH:PAINT( 1054 )
   Called from: .\source\classes\TGRAPH.PRG => (b)TGRAPH:TGRAPH( 116 )
   Called from:  => TGRAPH:DISPLAY( 0 )
   Called from: .\source\classes\CONTROL.PRG => TGRAPH:HANDLEEVENT( 1697 )
   Called from: .\source\classes\WINDOW.PRG => _FWH( 3305 )
   Called from:  => DIALOGBOXINDIRECT( 0 )
   Called from: .\source\classes\DIALOG.PRG => TDIALOG:ACTIVATE( 296 )
   Called from: .\source\function\ERRSYSW.PRG => ERRORDIALOG( 421 )
   Called from: .\source\function\ERRSYSW.PRG => (b)ERRORSYS( 23 )
   Called from: .\source\classes\TGRAPH.PRG => TGRAPH:PAINT( 1054 )
   Called from: .\source\classes\TGRAPH.PRG => TGRAPH:PRINT( 1782 )
   Called from: PEPPE.prg => TEST( 51 )
   Called from: PEPPE.prg => (b)MAIN( 11 )
   Called from: .\source\classes\WINDOW.PRG => TWINDOW:ACTIVATE( 1028 )
   Called from: PEPPE.prg => MAIN( 11 )


Changing

oGraph:lViewVal = .T.

to

oGraph:lViewVal = .F.

the error goes away.

Any suggestion?

EMG
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Bug in TGraph
Posted: Mon Sep 26, 2016 02:23 PM
Enrico, change line 1059

Code (fw): Select all Collapse
聽 聽 聽 聽 聽 聽 if ( ::aSeries[ nJ, 5 ] = NIL .OR. ::aSeries[ nJ, 5 ] ) .AND. ::aData[ nJ, nI ] <> NIL


with

Code (fw): Select all Collapse
聽 聽 聽 聽 聽 聽 if ( ::aSeries[ nJ, 5 ] = NIL .OR. ::aSeries[ nJ, 5] ) .AND. ::aData[ nJ, 1 ] <> NIL
Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noci贸n del tiempo

El secreto de la felicidad no est谩 en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Bug in TGraph
Posted: Mon Sep 26, 2016 02:39 PM
Thank you. Now I get

Code (fw): Select all Collapse
Argument error conditional


Sorry, I can't provide a sample.

EMG
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Bug in TGraph
Posted: Mon Sep 26, 2016 02:56 PM
You previous sample run now OK for me

Try, but, thik this not is the problem
Code (fw): Select all Collapse
            oGraph:aSeries = { { "Value", RGB( 109, 177, 124 ), 1, .F.,,,, } }
Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noci贸n del tiempo

El secreto de la felicidad no est谩 en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Bug in TGraph
Posted: Mon Sep 26, 2016 03:01 PM
cnavarro wrote:You previous sample run now OK for me


Yes, but the real code in my app doesn't. Here it is, but it's not compilable, sorry:

Code (fw): Select all Collapse
STATIC FUNCTION GRAFICO( cTit, aDat )

    LOCAL oPrn, oGraph

    LOCAL i

    PRNLANDSCAPE()

    PRINT oPrn NAME "Fatturato " + LOWER( cTit ) PREVIEW
        PAGE
            oGraph = TGraph():New()

            oGraph:lXGrid = .T.
            oGraph:lYGrid = .T.

            oGraph:lDotted  = .F.
            oGraph:lTitle   = .T.
            oGraph:lLegends = .F.

            oGraph:cTitle = "FATTURATO " + cTit

            oGraph:nBarSep = 100

            oGraph:lxVal = M -> ACS_LEVEL < 3
            oGraph:lViewVal = M -> ACS_LEVEL < 3

            oGraph:cTitX = "FATTURATO"
            oGraph:cTitY = "ANNI"

            oGraph:aSeries = { { "", RGB( 109, 177, 124 ), 1, .F. } }

            oGraph:aYVals = {}
            oGraph:aData = { {} }

            FOR i = 1 TO LEN( aDat )
                AADD( oGraph:aYVals, NTRIM( aDat[ i, 1 ] ) + IF( i > 1, " (" + NTRIM( aDat[ i, 2 ] ) + "%)", "" ) )
                AADD( oGraph:aData[ 1 ], aDat[ i, 3 ] )
            NEXT

            oGraph:Print( oPrn, 5 * oPrn:nVertRes() / 66, 5 * oPrn:nHorzRes() / 80, 70 * oPrn:nHorzRes() / 80, 56 * oPrn:nVertRes() / 66 )
        ENDPAGE
    ENDPRINT

    PRNPORTRAIT()

    RETURN NIL


EMG
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Bug in TGraph
Posted: Mon Sep 26, 2016 03:03 PM
The error pops up executing this line:

Code (fw): Select all Collapse
oGraph:Print( oPrn, 5 * oPrn:nVertRes() / 66, 5 * oPrn:nHorzRes() / 80, 70 * oPrn:nHorzRes() / 80, 56 * oPrn:nVertRes() / 66 )


EMG
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Bug in TGraph
Posted: Mon Sep 26, 2016 03:06 PM

Try:
- Create Graph into Dialog
- After, execute oGraph:Print

Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noci贸n del tiempo

El secreto de la felicidad no est谩 en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Bug in TGraph
Posted: Mon Sep 26, 2016 03:23 PM
This doesn't work, even with your fix:

Code (fw): Select all Collapse
#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oDlg

    DEFINE DIALOG oDlg

    ACTIVATE DIALOG oDlg;
             ON INIT TEST()

    RETURN NIL


EMG
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Bug in TGraph
Posted: Mon Sep 26, 2016 03:50 PM
Look your sample



Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noci贸n del tiempo

El secreto de la felicidad no est谩 en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Bug in TGraph
Posted: Mon Sep 26, 2016 04:32 PM

Did you try ma new sample using DIALOG?

EMG

Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Bug in TGraph
Posted: Mon Sep 26, 2016 05:15 PM
It is the same example

Code (fw): Select all Collapse
#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oWnd

    DEFINE WINDOW oWnd PIXEL 
    oWnd:nTop     := 10
    oWnd:nLeft    := 10
    oWnd:nWidth   := 600
    oWnd:nHeight  := 600
   
    ACTIVATE WINDOW oWnd;
             ON INIT Test1( TEST( oWnd ) )

    RETURN NIL


STATIC FUNCTION TEST( oWnd )

    LOCAL oGraph

            oGraph = TGraph():New()

            oGraph:lXGrid = .T.
            oGraph:lYGrid = .T.

            oGraph:lDotted  = .F.
            oGraph:lTitle   = .T.
            oGraph:lLegends = .F.

            oGraph:cTitle = "TEST"

            oGraph:nBarSep = 100

            oGraph:lxVal = .T.
            oGraph:lViewVal = .T.

            oGraph:cTitX = "TESTX"
            oGraph:cTitY = "TESTY"

            oGraph:aSeries = { { "Value", RGB( 109, 177, 124 ), 1, .F.,,,, } }

            oGraph:aYVals = {}
            oGraph:aData = { {} }

            AADD( oGraph:aYVals, "2016" )
            AADD( oGraph:aData[ 1 ], 100 )

            oWnd:oClient  := oGraph
            
            //if MsgYesNo( "Print Graph", "Attention:" )
            //   Test1( oGraph )
            //endif
RETURN oGraph

//----------------------------------------------------------------------------//

STATIC FUNCTION TEST1( oGraph )

    LOCAL oPrn

    PRNLANDSCAPE()

    PRINT oPrn NAME "Test" PREVIEW
        PAGE
            oGraph:Print( oPrn, 5 * oPrn:nVertRes() / 66, 5 * oPrn:nHorzRes() / 80, 70 * oPrn:nHorzRes() / 80, 56 * oPrn:nVertRes() / 66 )
        ENDPAGE
    ENDPRINT

    PRNPORTRAIT()

RETURN NIL

//----------------------------------------------------------------------------//
Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noci贸n del tiempo

El secreto de la felicidad no est谩 en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Bug in TGraph
Posted: Mon Sep 26, 2016 05:25 PM
This is the sample that doesn't work:

Code (fw): Select all Collapse
#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oDlg

    DEFINE DIALOG oDlg

    ACTIVATE DIALOG oDlg;
             ON INIT TEST()

    RETURN NIL


STATIC FUNCTION TEST()

    LOCAL oPrn, oGraph

    PRNLANDSCAPE()

    PRINT oPrn NAME "Test" PREVIEW
        PAGE
            oGraph = TGraph():New()

            oGraph:lXGrid = .T.
            oGraph:lYGrid = .T.

            oGraph:lDotted  = .F.
            oGraph:lTitle   = .T.
            oGraph:lLegends = .F.

            oGraph:cTitle = "TEST"

            oGraph:nBarSep = 100

            oGraph:lxVal = .T.
            oGraph:lViewVal = .T.

            oGraph:cTitX = "TESTX"
            oGraph:cTitY = "TESTY"

            oGraph:aSeries = { { "", RGB( 109, 177, 124 ), 1, .F. } }

            oGraph:aYVals = {}
            oGraph:aData = { {} }

            AADD( oGraph:aYVals, "2016" )
            AADD( oGraph:aData[ 1 ], 100 )

            oGraph:Print( oPrn, 5 * oPrn:nVertRes() / 66, 5 * oPrn:nHorzRes() / 80, 70 * oPrn:nHorzRes() / 80, 56 * oPrn:nVertRes() / 66 )
        ENDPAGE
    ENDPRINT

    PRNPORTRAIT()

    RETURN NIL


EMG
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Bug in TGraph
Posted: Mon Sep 26, 2016 05:26 PM
The error is in the line

Code (fw): Select all Collapse
::oWnd:ReleaseDC()


inside the Print() method.

EMG
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Bug in TGraph
Posted: Mon Sep 26, 2016 06:02 PM

Another problem in Paint() method:

::aSeries[nJ,5]

contains NIL.

EMG

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Bug in TGraph
Posted: Mon Sep 26, 2016 06:11 PM
Works fine if

Code (fw): Select all Collapse
oGraph:aSeries = { { "", RGB( 109, 177, 124 ), 1, .F. } }


is replaced with

Code (fw): Select all Collapse
oGraph:aSeries = { { "", RGB( 109, 177, 124 ), 1, .F., .T. } }


It seems that the fifth item of aSeries lost its default value (previously it had one, don't know since which FWH release).

Anyway, problem solved for me. But a proper fix would be welcome. :-)

EMG