FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Bound error: Array access
Posts: 1467
Joined: Mon Oct 10, 2005 11:26 AM
Bound error: Array access
Posted: Fri Feb 06, 2009 10:52 AM

Hello,

I have a strange problem in a wbrowse.

This is a part of the code :

SET KEY VK_DELETE TO tDelete
...............
REDEFINE LISTBOX oLbx ID 101 OF oDlg  FIELDS "","","","" .......
oLbx:bLine := {||{Fld1,Fld2,Fld3,Fld4,...}}
...............
REDEFIN BUTTON ID 901 OF oDlg ACTION tDelete()
...............

STATIC PROCEDURE tDELETE
// This procedure performs the delete-function of the choosen line in the wbrowse.

So I have defined the Delete-button of my keyboard as the button which performs tDelete().

If the focus is on the last line of the wbrowse and I click with my mouse on the "DELETE" button in my dialog box, everything is happening as it should be : the last line of my wbrowse is deleted and my wbrowse is updated and refreshed.

But if the focus still is on the last line of the wbrowse and I push the Delete-button of my keyboard, I always get a "Bound error: Array access", refering to the line of the oLbx:bLine.

Why does it work if a pushbutton in the dialogbox is used and why doesn't it worked if a linked key on my keyboard is used, although it performs exactly the same procedure ?

I also noticed that, if I click on any line but the last line and I go back to the last line to delete it, both possibilities for deletion perform without any error.

Thanks a lot in advance.

Regards,

Regards,

Michel D.
Genk (Belgium)


_____________________________________________________________________________________________

I use : FiveWin for (x)Harbour v. 25.12 - Harbour 3.2.0 (May 2025) - xHarbour Builder (January 2020) - Bcc773

Posts: 8523
Joined: Tue Dec 20, 2005 07:36 PM
Re: Bound error: Array access
Posted: Fri Feb 06, 2009 11:26 AM
Hi, please add:

    oLbx:aJustify      := { .T., .F., .F., .F., .F., .F., .F., .F., .F. }
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 1467
Joined: Mon Oct 10, 2005 11:26 AM
Re: Bound error: Array access
Posted: Fri Feb 06, 2009 11:49 AM

Thanks for your answer, but that line already is in my source. So that is not the reason for the problem.

But thanks anyway for your effort.

Regards,

Michel D.
Genk (Belgium)


_____________________________________________________________________________________________

I use : FiveWin for (x)Harbour v. 25.12 - Harbour 3.2.0 (May 2025) - xHarbour Builder (January 2020) - Bcc773

Posts: 824
Joined: Thu Oct 13, 2005 07:39 AM
Re: Bound error: Array access
Posted: Fri Feb 06, 2009 11:54 AM

Michel,

you have to update record pointer, add (<cAlias>)->dbGoBottom() or dbSkip (0) before refreshing the browse

kind regards

Stefan
Posts: 1467
Joined: Mon Oct 10, 2005 11:26 AM
Re: Bound error: Array access
Posted: Fri Feb 06, 2009 12:37 PM

Stefan,

My wbrowse contains an array, not a DBF-file directly.

Thanks.

Regards,

Michel D.
Genk (Belgium)


_____________________________________________________________________________________________

I use : FiveWin for (x)Harbour v. 25.12 - Harbour 3.2.0 (May 2025) - xHarbour Builder (January 2020) - Bcc773

Posts: 2365
Joined: Wed Nov 02, 2005 11:46 PM
Re: Bound error: Array access
Posted: Fri Feb 06, 2009 03:04 PM

hello driessen

what do you use, harbour or xHarbour
how do you delete?

Posts: 824
Joined: Thu Oct 13, 2005 07:39 AM
Re: Bound error: Array access
Posted: Fri Feb 06, 2009 03:30 PM
Michel,

driessen wrote:Stefan,

My wbrowse contains an array, not a DBF-file directly.

Thanks.


for an array you can use oBrw:GoBottom () or update oBrw:bLogicLen and set it to the new array length.

I had a similar problem, my solution was to manipulate the array outside the wbrowse object and to renew the array with oBrw:SetArray(...) every time I delete or add an array element.
kind regards

Stefan
Posts: 845
Joined: Sun Oct 09, 2005 05:36 PM
Re: Bound error: Array access
Posted: Fri Feb 06, 2009 06:20 PM

Driessen,
i use wbrowse with array in this sample:

 aDatos := {}

 REDEFINE LISTBOX oLbx FIELDS &quot;&quot; ;
                     HEADER &quot;&quot;, &quot;Cantidad&quot;, &quot;U.M.&quot;, &quot;Descripción&quot;, &quot;Observaciones&quot; ;
                     SIZES 20, 60, 44, 290, 264 ;
                     ID 116 OF oDlg FONT oFnt[1] UPDATE

       oLbx:bLine:= {|nAt| nAt:= oLbx:nAt,                      ;
                           If( Len(aDatos)&lt;1 .or. nAt&gt;Len(aDatos),;
                             Array(5),                            ;
                             { If( oLbx!=Nil .and. oLbx:lSelect, hBmp, 0 ),;
                               Transform( aDatos[nAt,1],&quot;99,999.999&quot; ),;
                               aDatos[nAt,2],;
                               aDatos[nAt,3],;
                               aDatos[nAt,4] } ) }

       oLbx:SetArray( aDatos )

Regards
Paco

____________________

Paco

Continue the discussion