Page 1 of 1

bound error in Loop checkbox

Posted: Mon Oct 19, 2015 6:07 am
by dbmanfwh
Everyone,

I don't understand why bound error occurs.

Code: Select all

#include "fivewin.ch"

Function main()

   LOCAL oDlg
   LOCAL oBtn

   LOCAL aJob := {}
   LOCAL oGet := {}
   LOCAL aGet := {}

   LOCAL nRow := 0
   LOCAL nI   := 0


   AADD( aJob, {"First"     , {|| MsgInfo(1)  } } )
   AADD( aJob, {"Second"    , {|| MsgInfo(2)  } } )
   AADD( aJob, {"Third"     , {|| MsgInfo(3)  } } )

   oGet := ARRAY( LEN(aJob) )
   aGet := ARRAY( LEN(ajob) )

   AFILL( aGet, .t. )

   DEFINE DIALOG oDlg SIZE 200, 200 TITLE "CheckBox Test"  PIXEL

      For nI := 1 to LEN( aJob )
         nRow+=9
         @ nRow, 20 CHECKBOX oGet[nI]  VAR aGet[nI]  PROMPT aJob[nI][1] SIZE 80,9 OF oDlg  PIXEL
      Next

      nRow+=19
      @ nRow, 20 BUTTON oBtn PROMPT "End" SIZE 35, 15 OF oDlg PIXEL ACTION oDlg:End()

   ACTIVATE DIALOG oDlg  CENTER

RETURN NIL
 

Code: Select all

Application
===========
   Path and name: C:\FiveWin\samples\testcheckbox.exe (32 bits)
   Size: 3,045,888 bytes
   Compiler version: Harbour 3.2.0dev (r1501292255)
   FiveWin  Version: FWH 15.04
   Windows version: 6.1, Build 7601 Service Pack 1

   Time from start: 0 hours 0 mins 0 secs 
   Error occurred at: 10/19/15, 14:59:02
   Error description: Error BASE/1132  Bound error: array access
   Args:
     [   1] = A   { ... } length: 3
     [   2] = N   4

Stack Calls
===========
   Called from: testcheckbox.prg => (b)MAIN( 29 )
   Called from: .\source\classes\CHECKBOX.PRG => TCHECKBOX:INITIATE( 187 )
   Called from:  => __OBJSENDMSG( 0 )
   Called from: .\source\function\HARBOUR.PRG => OSEND( 288 )
   Called from: .\source\function\HARBOUR.PRG => ASEND( 256 )
   Called from: .\source\classes\DIALOG.PRG => TDIALOG:INITIATE( 648 )
   Called from: .\source\classes\DIALOG.PRG => TDIALOG:HANDLEEVENT( 893 )
   Called from:  => DIALOGBOXINDIRECT( 0 )
   Called from: .\source\classes\DIALOG.PRG => TDIALOG:ACTIVATE( 289 )
   Called from: testcheckbox.prg => MAIN( 35 )

Variables in use
================
   Procedure     Type   Value
   ==========================
   (b)MAIN
     Param   1:    O    Class: ERROR
   TCHECKBOX:INITIATE
     Local   1:    U    
     Local   2:    A    Len:    3
     Local   3:    N    4
     Local   4:    U    
     Local   5:    U    
   __OBJSENDMSG
     Param   1:    N    788118
     Local   1:    S    
     Local   2:    O    Class: TCHECKBOX
     Local   3:    N    241
   OSEND
     Param   1:    O    Class: TCHECKBOX
     Param   2:    C    "INITIATE"
     Param   3:    N    788118
 

Re: bound error in Loop checkbox

Posted: Mon Oct 19, 2015 9:54 am
by Enrico Maria Giordano
Moon,

Code: Select all

#include "fivewin.ch"

Function main()

   LOCAL oDlg
   LOCAL oBtn

   LOCAL aJob := {}
   LOCAL oGet
   LOCAL aGet

   LOCAL nRow := 0
   LOCAL nI


   AADD( aJob, {"First"     , {|| MsgInfo(1)  } } )
   AADD( aJob, {"Second"    , {|| MsgInfo(2)  } } )
   AADD( aJob, {"Third"     , {|| MsgInfo(3)  } } )

   oGet := ARRAY( LEN(aJob) )
   aGet := ARRAY( LEN(ajob) )

   AFILL( aGet, .t. )

   DEFINE DIALOG oDlg SIZE 200, 200 TITLE "CheckBox Test"  PIXEL

      For nI := 1 to LEN( aJob )
         nRow+=9
         CREATECHECKBOX( oDlg, oGet, aGet, aJob, nRow, nI )
      Next

      nRow+=19
      @ nRow, 20 BUTTON oBtn PROMPT "End" SIZE 35, 15 OF oDlg PIXEL ACTION oDlg:End()

   ACTIVATE DIALOG oDlg  CENTER

RETURN NIL


STATIC FUNCTION CREATECHECKBOX( oDlg, oGet, aGet, aJob, nRow, nI )

   @ nRow, 20 CHECKBOX oGet[nI]  VAR aGet[nI]  PROMPT aJob[nI][1] SIZE 80,9 OF oDlg  PIXEL

   RETURN NIL
EMG

Re: bound error in Loop checkbox

Posted: Mon Oct 19, 2015 1:13 pm
by dbmanfwh
EMG,

Thank you.
However, it is doubt that must use perfect logic in this way to when grammatically.
I think that it is subject to solve Harbour, xHarbour or someone.

Re: bound error in Loop checkbox

Posted: Mon Oct 19, 2015 1:44 pm
by Enrico Maria Giordano
Moon,

no, it's not a bug, it is the well known "detached local" behaviour of the codeblocks.

EMG