udfItemListRandom
udfItemListRandomStep
str udfItemListRandom (int, int, str)
str udfItemListRandomStep (int, int, int, str)
;------------------------------------------------------------------------------------------------------------------------------------------
#DefineFunction udfItemListRandom (intLow, intHigh, strDelimiter)
strItemList = ""
intRange = intHigh - intLow
intCount = 1 + intRange
While ItemCount (strItemList, strDelimiter) < intCount
   intNum = intLow + Random (intRange)
   If !ItemLocate (intNum, strItemList, strDelimiter) Then strItemList = ItemInsert (intNum, -1, strItemList, strDelimiter)
EndWhile
Return strItemList
;..........................................................................................................................................
; This UDF udfItemListRandom creates an ItemList with (1 + intHigh - intLow) items
; of random value in the range from intLow to intHigh.
;..........................................................................................................................................
#EndFunction
;------------------------------------------------------------------------------------------------------------------------------------------

;------------------------------------------------------------------------------------------------------------------------------------------
#DefineFunction udfItemListRandomStep (intLow, intHigh, intStep, strDelimiter)
strItemList = ""
intCount = (intHigh - intLow) / Max (intStep, 1)
While ItemCount (strItemList, strDelimiter) <= intCount
   intNum = intLow + (intStep * (Random (intCount) mod (1 + intCount)))
   If !ItemLocate (intNum, strItemList, strDelimiter) Then strItemList = ItemInsert (intNum, -1, strItemList, strDelimiter)
EndWhile
Return strItemList
;..........................................................................................................................................
; This UDF udfItemListRandomStep creates an ItemList with (1 + ((intHigh - intLow) / intStep)) items
; of random value in the range from intLow to intHigh in stepwidth of intStep.
;..........................................................................................................................................
#EndFunction
;------------------------------------------------------------------------------------------------------------------------------------------


; Test.

strRandomList1 = udfItemListRandom (1, 6, ",")          ; 6 items e. g. "2,5,3,6,1,4"
strRandomList2 = udfItemListRandom (3, 11, ",")         ; 9 items e. g. "9,8,6,10,11,7,5,3,4"

strRandomList3 = udfItemListRandomStep (5, 25, 5, "|")  ; 5 items e. g. "5|25|10|20|15"
strRandomList4 = udfItemListRandomStep (5, 25, 3, "-")  ; 7 items e. g. "5-14-11-20-8-23-17"

Exit