DC_GetColArray() - suggestion
Posted: Mon Sep 07, 2015 9:30 am
Hi, Roger.
I do use DC_GetColArray() intensively in the DATA codeblocks of all my array browers. But if those arrays are empty, maybe in a statistics module, all DC_GetColArray()-calls return empty strings. So now, I have to catch the length of the array source inside all codeblocks (DATA {||IF(Len(oBrowse:dataSource)>0,"--",DtoC(DC_GetColArray(1,oBrowse)))}), which is not very elegant. What about a forth parameter setting a DEFAULT value?
My codeblocks could changed to this with a default for DC_GetColArray():
I do use DC_GetColArray() intensively in the DATA codeblocks of all my array browers. But if those arrays are empty, maybe in a statistics module, all DC_GetColArray()-calls return empty strings. So now, I have to catch the length of the array source inside all codeblocks (DATA {||IF(Len(oBrowse:dataSource)>0,"--",DtoC(DC_GetColArray(1,oBrowse)))}), which is not very elegant. What about a forth parameter setting a DEFAULT value?
Code: Select all
FUNCTION DC_GetColArray( nElement, oBrowse, xVar, xDefault ) // here
LOCAL aArray, nPointer, xValue
DEFAULT xDefault := '' // here
aArray := oBrowse:dataSource
nPointer := oBrowse:arrayElement
IF nPointer > Len(aArray) .OR. nPointer = 0
RETURN xDefault // and here
ENDIF
IF nElement == NIL
RETURN aArray[nPointer]
ELSEIF nElement <= 0
RETURN nPointer
ENDIF
xValue := aArray[nPointer,nElement]
IF Valtype(xVar) == Valtype(xValue) // should work anyway
aArray[nPointer,nElement] := xVar
ENDIF
RETURN aArray[nPointer,nElement]
Code: Select all
DATA {||DtoC(DC_GetColArray(1,oBrowse,,EmptyDate()))}