udfCreateTestNumberString
;------------------------------------------------------------------------------------------------------------------------------------------
#DefineFunction udfCreateTestNumberString (intLength, strDelimiter, intDirection)
If intLength < 1 Then Return ""
strDelimiter = StrSub (strDelimiter, 1, 1)
strString = ""
Switch !!intDirection
Case 0
   While intLength > 1
      strString = strDelimiter : intLength : strString
      intLength = intLength - StrLen (intLength) - 1
   EndWhile
   If intLength == 1 Then strString = "1" : strString
   Break
Case 1
   While intLength > 1
      strString = strString : intLength : strDelimiter
      intLength = intLength - StrLen (intLength) - 1
   EndWhile
   If intLength == 1 Then strString = strString : "1"
   Break
EndSwitch
Return strString
;..........................................................................................................................................
; This UDF "udfCreateTestNumberString" creates a string of the specified length consisting of numbers
; separated by the specified delimiter such that each number is equal to the number of chars counted
; from the left side until behind the number (e. g. "1-3-5")
; resp. from the right side until the beginning of the number (e. g. "5-3-1").
;
; Adapted from a proposal by "MarkLTX", posted: 8 Sep 2007, updated: 9 Aug 2008, on "The Code Project" website.
; "Generate Meta-Strings for Testing Your Application", "http://www.codeproject.com/KB/recipes/MetaString.aspx".
;
; Parameters:
;    intLength ...... Length of the number string.
;    strDelimiter ... Delimiter character between numbers.
;    intDirection ... 0 = Count from left to right.
;                     1 = Count from right to left.
;
; (c)Detlev Dalitz.20080812.20100226.
;..........................................................................................................................................
#EndFunction
;------------------------------------------------------------------------------------------------------------------------------------------


; Test

strOut = ""

; Count from left to right.
For IntI = 0 To 19
   strOut = ItemInsert (udfCreateTestNumberString (IntI, "-", 0), -1, strOut, @LF)
Next


; Count from right to left.
For IntI = 19 To 0 By -1
   strOut = ItemInsert (udfCreateTestNumberString (IntI, "-", 1), -1, strOut, @LF)
Next


ClipPut (StrReplace (strOut, @LF, @CRLF))
strAsk = AskItemlist ("Test: udfCreateTestNumberString", strOut, @LF, @UNSORTED, @SINGLE, @FALSE)

:CANCEL
Exit

;------------------------------------------------------------------------------------------------------------------------------------------
; Test output
;------------------------------------------------------------------------------------------------------------------------------------------
; 1
; -2
; 1-3
; -2-4
; 1-3-5
; -2-4-6
; 1-3-5-7
; -2-4-6-8
; 1-3-5-7-9
; 1-3-5-7-10
; -2-4-6-8-11
; 1-3-5-7-9-12
; 1-3-5-7-10-13
; -2-4-6-8-11-14
; 1-3-5-7-9-12-15
; 1-3-5-7-10-13-16
; -2-4-6-8-11-14-17
; 1-3-5-7-9-12-15-18
; 1-3-5-7-10-13-16-19
; 19-16-13-10-7-5-3-1
; 18-15-12-9-7-5-3-1
; 17-14-11-8-6-4-2-
; 16-13-10-7-5-3-1
; 15-12-9-7-5-3-1
; 14-11-8-6-4-2-
; 13-10-7-5-3-1
; 12-9-7-5-3-1
; 11-8-6-4-2-
; 10-7-5-3-1
; 9-7-5-3-1
; 8-6-4-2-
; 7-5-3-1
; 6-4-2-
; 5-3-1
; 4-2-
; 3-1
; 2-
; 1
;------------------------------------------------------------------------------------------------------------------------------------------