SetDlgGradient() PRODUCE ERROR on tSay class

SetDlgGradient() PRODUCE ERROR on tSay class

Postby avista » Fri Sep 06, 2013 10:08 pm

Hi,

Code: Select all  Expand view

#INCLUDE "fivewin.ch"

FUNCTION Main()

   LOCAL oDlg
   LOCAL aText := { "Text1" , "Text2" }
   LOCAL i := 0

   SetDlgGradient( { { 1, RGB( 199, 216, 237 ), RGB( 237, 242, 248 ) } } )

   DEFINE DIALOG oDlg TITLE "Test" SIZE 200,400

   FOR i = 1 to LEN( aText )
       @ i*15, 5 SAY aText[ i ] OF oDlg PIXEL
   NEXT

   ACTIVATE DIALOG oDlg CENTER

RETURN NIL
 


Error description: Error BASE/1132 Bound error: array access
Args:
[ 1] = A { ... }
[ 2] = N 3

Stack Calls
===========
Called from: brisi.prg => (b)MAIN( 14 )
Called from: .\source\classes\SAY.PRG => (b)TSAY:TSAY( 51 )
Called from: => TSAY:REFRESH( 0 )
Called from: .\source\classes\WINDOW.PRG => (b)TWINDOW:TWINDOW( 566 )
Called from: => TSAY:SETBRUSH( 0 )
Called from: .\source\classes\CONTROL.PRG => TCONTROL:INITIATE( 417 )
Called from: .\source\classes\SAY.PRG => TSAY:INITIATE( 196 )
Called from: => __OBJSENDMSG( 0 )
Called from: => HB_EXECFROMARRAY( 0 )
Called from: .\source\function\HARBOUR.PRG => OSEND( 279 )
Called from: => HB_EXECFROMARRAY( 0 )
Called from: .\source\function\HARBOUR.PRG => ASEND( 257 )
Called from: .\source\classes\DIALOG.PRG => TDIALOG:INITIATE( 631 )
Called from: .\source\classes\DIALOG.PRG => TDIALOG:HANDLEEVENT( 871 )
Called from: => DIALOGBOXINDIRECT( 0 )
Called from: .\source\classes\DIALOG.PRG => TDIALOG:ACTIVATE( 270 )
Called from: brisi.prg => MAIN( 18 )

IF comment line
// SetDlgGradient( { { 1, RGB( 199, 216, 237 ), RGB( 237, 242, 248 ) } } )
program work ok

Any idea ?

Best regards,
User avatar
avista
 
Posts: 301
Joined: Fri Jun 01, 2007 9:07 am
Location: Macedonia

Re: SetDlgGradient() PRODUCE ERROR on tSay class

Postby avista » Fri Sep 06, 2013 11:01 pm

In this CASE:

Code: Select all  Expand view

#INCLUDE "fivewin.ch"

FUNCTION Main()

   LOCAL oDlg
   LOCAL aText := { "Text 1111", "Text 2222", "Text 3333", "Text 4444" }
   LOCAL cText := ""
   LOCAL i := 0

   SetDlgGradient( { { 1, RGB( 199, 216, 237 ), RGB( 237, 242, 248 ) } } )

   DEFINE DIALOG oDlg TITLE "Test" SIZE 200,400

   FOR i = 1 to LEN( aText )
       cText := aText[ i ]
       @ i*15, 5 SAY cText      OF oDlg PIXEL

//     @ i*15, 5 SAY aText[ i ] OF oDlg PIXEL
   NEXT

   ACTIVATE DIALOG oDlg CENTER

RETURN NIL
 


Program work BUT in all 4 cases is displayed the same valye ... only last value from the array
IF comment line
// SetDlgGradient( { { 1, RGB( 199, 216, 237 ), RGB( 237, 242, 248 ) } } )
program work ok

Best Regards,
User avatar
avista
 
Posts: 301
Joined: Fri Jun 01, 2007 9:07 am
Location: Macedonia

Re: SetDlgGradient() PRODUCE ERROR on tSay class

Postby Enrico Maria Giordano » Sat Sep 07, 2013 6:44 am

You have to use detached local because i is 3 when the dialog is activated:

Code: Select all  Expand view
#INCLUDE "fivewin.ch"

FUNCTION Main()

   LOCAL oDlg
   LOCAL aText := { "Text1" , "Text2" }
   LOCAL i

   SetDlgGradient( { { 1, RGB( 199, 216, 237 ), RGB( 237, 242, 248 ) } } )

   DEFINE DIALOG oDlg TITLE "Test" SIZE 200,400

   FOR i = 1 to LEN( aText )
       MAKESAY( oDlg, aText, i )
   NEXT

   ACTIVATE DIALOG oDlg CENTER

RETURN NIL


STATIC FUNCTION MAKESAY( oDlg, aText, n )

    @ n*15, 5 SAY aText[ n ] OF oDlg PIXEL

    RETURN NIL


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8713
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: SetDlgGradient() PRODUCE ERROR on tSay class

Postby avista » Sat Sep 07, 2013 3:47 pm

Enrico
Thanks for reply

I only dont understand why this sample is working

Code: Select all  Expand view

#INCLUDE "fivewin.ch"

FUNCTION Main()

   LOCAL oDlg
   LOCAL aText := { "Text1" , "Text2" }
   LOCAL i := 0

   DEFINE DIALOG oDlg TITLE "Test" SIZE 200,400

   FOR i = 1 to LEN( aText )
       @ i*15, 5 SAY aText[ i ] OF oDlg PIXEL
   NEXT

   ACTIVATE DIALOG oDlg CENTER

RETURN NIL
 


Problem is in bouth cases only if i add line
SetDlgGradient( { { 1, RGB( 199, 216, 237 ), RGB( 237, 242, 248 ) } } )

Btw i use that logic in many functions so i must change them all ...or not use SetDlgGradient()

Regards,
User avatar
avista
 
Posts: 301
Joined: Fri Jun 01, 2007 9:07 am
Location: Macedonia

Re: SetDlgGradient() PRODUCE ERROR on tSay class

Postby Enrico Maria Giordano » Sat Sep 07, 2013 5:27 pm

avista wrote:Enrico
Thanks for reply

I only dont understand why this sample is working


Because it forced the loop current i value to become attached to the current SAY codeblock (have a look at the well known detached locals technique).

avista wrote:Problem is in bouth cases only if i add line
SetDlgGradient( { { 1, RGB( 199, 216, 237 ), RGB( 237, 242, 248 ) } } )


No, the problem is independent from SetDlgGradient() function. Please try this sample (click on Test button):

Code: Select all  Expand view
#INCLUDE "fivewin.ch"

FUNCTION Main()

   LOCAL oDlg
   LOCAL aText := { "Text1" , "Text2" }
   LOCAL i := 0

   DEFINE DIALOG oDlg TITLE "Test" SIZE 200,400

   FOR i = 1 to LEN( aText )
       @ i*15, 5 SAY aText[ i ] OF oDlg PIXEL
   NEXT

   @ 45, 5 BUTTON "Test" PIXEL;
           ACTION oDlg:aControls[ 1 ]:Refresh()

   ACTIVATE DIALOG oDlg CENTER

RETURN NIL


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8713
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia


Return to FiveWin for Harbour/xHarbour

Who is online

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