udfArrayDumpToItemList
str udfArrayDumpToItemList (arr, str)
;------------------------------------------------------------------------------------------------------------------------------------------
#DefineFunction udfArrayDumpToItemList (arrArray, strDelimiter)
If !ArrInfo (arrArray, -1) Then Return "*ARR_INVALID*" ; No Array, return invalid itemlist, i. e. empty string "".
If ArrInfo (arrArray, 0) != 1 Then Return "*ARR_DIM_ERROR*" ; Array is not a dim-1 array, return invalid itemlist, i. e. empty string "".
intElements = ArrInfo (arrArray, 1)
If intElements == 0 Then Return ""
intHigh = intElements - 1
intLow = 0
strItemList = ""
For intI = intLow To intHigh
   If !!VarType (arrArray [intI])
      If arrArray [intI] == ""
         strItemList = ItemInsert ("*ARR_ELEM_EMPTY*", -1, strItemList, strDelimiter)
      Else
         strItemList = ItemInsert ("[" : arrArray [intI] : "]", -1, strItemList, strDelimiter)
      EndIf
   Else
      strItemList = ItemInsert ("*ARR_ELEM_UNDEF*", -1, strItemList, strDelimiter)
   EndIf
Next
Return strItemList
;..........................................................................................................................................
; This UDF "udfArrayDumpToItemList" reads a dim-1 array and returns an itemlist of all array cell items.
;
; Return values:
; "*ARR_INVALID*"    ... Invalid array resp. this is no array.
; "*ARR_DIM_ERROR*"  ... Array is not a dim-1 array.
; "*ARR_ELEM_EMPTY*" ... Array element has defined vartype but is empty.
; "*ARR_ELEM_UNDEF*" ... Array element has undefined VarType.
; [value]            ... Current value of the array element.
;
; Example: strItemList = udfArrayDumpToItemList (arrArray, @TAB)
;
; Detlev Dalitz.20090515.20100122.
;..........................................................................................................................................
#EndFunction
;------------------------------------------------------------------------------------------------------------------------------------------


; Test.

strMsgTitle = "Demo: udfArrayDumpToItemList (arrArray, strDelimiter)"
strMsgText = ""

strDelimiter = ","
strItemList = ",a,b,c,ABC,-11,11,3.14" ; 8 Items.


:Test1
arrA = "abc" ; This is NO array!
strItemList1 = udfArrayDumpToItemList (arrA, strDelimiter) ; "*ARR_INVALID*"
strMsgText = "Test 1" : @LF : @LF : strItemList1
Message (strMsgTitle, strMsgText)


:Test2
arrB = ArrDimension (0) ; This is a valid dim-0 array but contains no elements.
strItemList2 = udfArrayDumpToItemList (arrB, strDelimiter) ; "*ARR_DIM_ERROR*"
strMsgText = "Test 2" : @LF : @LF : strItemList2
Message (strMsgTitle, strMsgText)


:Test3
arrC = Arrayize (strItemList, strDelimiter)

strItemList3 = udfArrayDumpToItemList (arrC, strDelimiter) ; "*ARR_ELEM_EMPTY*,a,b,c,ABC,-11,11,3.14"
strMsgText = "Test 3" : @LF : @LF : strItemList3
Message (strMsgTitle, strMsgText)


:Test4
arrD = ArrDimension (3)
strItemList4 = udfArrayDumpToItemList (arrD, strDelimiter) ; "*ARR_ELEM_UNDEF*,*ARR_ELEM_UNDEF*,*ARR_ELEM_UNDEF*"
strMsgText = "Test 4" : @LF : @LF : strItemList4
Message (strMsgTitle, strMsgText)


:Test5
strDelimiter = ","
arrE = Arrayize (",", strDelimiter)
strItemList5 = udfArrayDumpToItemList (arrE, strDelimiter) ; "*ARR_ELEM_EMPTY*,*ARR_ELEM_EMPTY*"
strMsgText = "Test 5" : @LF : @LF : strItemList5
Message (strMsgTitle, strMsgText) ;

Exit