>Hi Gang!
>
>My fellow colleague at work has this problem. He has this in some code
>
>
>PROCEDURE getArrayElement
> PARAMETERS lnElement
> pcTheData = laWarnLbl[lnElement]
> RETURN pcTheData
>ENDPROC
>
>
>The above snippet of code is giving me the “invalid subscript reference” error on the “pcTheData = laWarnLbl[lnElement] line.
>
>The value of lnElement at this point is 1.
>
>And laWrnLbl is dimensioned to 6.
>
>Thanks
If you have a field called lnElement in the active table, and it has a value greater than 6, you will get this error. I strongly advise you to alter this routine so that it uses LPARAMETERS. It should receive the array as a parameter too. It should declare pcTheData LOCAL or not even use pcTheData at all. I'd write it this way.
getArrayElement.prg
LPARAMETERS lnElement,taArray
EXTERNAL ARRAY taArray
RETURN taArray[m.lnElement]
and I'd call it like this
?GetArrayElement(5,@laWarnLbl)