Page 1 of 1

Error in Array Index

Posted: Tue Jun 21, 2016 6:45 am
by omni
Roger,

This one is driving me crazy.Code has been the same on this since we wrote the program. (too long ago to remember)

We initialize here at the top of the program when it opens:


select 36
use appttype
set order to
goto top
DECLARE Alist[RECCOUNT()]
DECLARE Clist[RECCOUNT()]
Z=1
DO WHILE Z<=RECCOUNT()
STORE apptDESC TO Alist[Z]
STORE apptCODE TO Clist[Z]
Z=Z+1
SKIP

ENDDO


Get is here:

@ 15,8 DCCOMBOBOX TYPE XBPCOMBO_DROPDOWNLIST cStyp LIST aLIST SIZE 12,zn ;
ITEMSELECTED {||vdshipappt:=cList[ASCAN(aList,cStyp)],dc_getrefresh(getlist) }


Get this message when they are updating (but only on rare occasions)

oError:args :
-> VALTYPE: A VALUE: {"C", "F", "D", "N", "R", "W"}
-> VALTYPE: N VALUE: 0
oError:description : Error in array index
oError:filename :
oError:genCode : 4
oError:operation : <A of 6>[<0>]



Only happens in one location, and only once every 2000-3000 times they are in what we call our booking screen.

Does this mean that the var vdshipappt is a numeric zero? Its always one of those character codes listed. There are two such combo boxes with the same choices and it happens sometimes on one, sometimes on the other. At this point just clarifying that the program at that moment thinks the var is a numeric 0.


Thanks

Fred
Omni

Re: Error in Array Index

Posted: Tue Jun 21, 2016 8:03 am
by rdonnay
I need to know what line of code is causing the error?

Is this in the DC_XbpComboBox class or in your code?

Re: Error in Array Index

Posted: Tue Jun 21, 2016 10:21 am
by omni
Here is the rest of the message.

oError:description : Error in array index
oError:filename :
oError:genCode : 4
oError:operation : <A of 6>[<0>]
CALLSTACK:
Called from (B)BOOKWIN(1096)
Called from (B)DC_MERGEBLOCKS(184)
Called from DC_GETLIST:EVENTLOOP(4704)
Called from DC_GETLIST:READGUI(3871)
Called from DC_READGUI(113)

Re: Error in Array Index

Posted: Tue Jun 21, 2016 11:25 am
by rdonnay
Show me your code.

Especially BookWin (1096).

There needs to be a test to make sure that the index into the array is not a ZERO value.

Re: Error in Array Index

Posted: Wed Jun 22, 2016 12:07 am
by skiman
Hi,

Maybe a user is pressing ESCAPE in the combobox? If the value of cStyp isn't found with your ascan you could get this kind of error.

Re: Error in Array Index

Posted: Wed Jun 22, 2016 5:53 am
by Cliff Wiernik
I've experienced this in the past and wrapped the ascan function to return a default as I could not determine the cause.