udfStrParseToArray
arr udfStrParseToArray (str)
;------------------------------------------------------------------------------------------------------------------------------------------
#DefineFunction udfStrParseToArray (strString)
intParams = ParseData (strString)
arrParam = ArrDimension (intParams)
For intElem = 1 To intParams
   arrParam [intElem - 1] = Param%intElem%
Next
Return arrParam
;..........................................................................................................................................
; This UDF "udfStrParseToArray" returns a Dim-1 array.
; Each cell is populated with one parameter parsed from the given string.
;
; A group of white spaced words, which are enclosed by a pair of apostrophe chars,
; e. g. "a b c" or 'a b c' or `a b c`, is treated as one parameter.
;
; The total number of parameters to be extracted depends on the total number of declared variables while runtime.
; There is a standard limit of about 2000 variables overall in WinBatch.
;
; Detlev Dalitz.20040325
;..........................................................................................................................................
#EndFunction
;------------------------------------------------------------------------------------------------------------------------------------------


; Test.

strMsgTitle = "Demo: udfStrParseToArray (strString)"

intTest = 1
strString = IntControl (1006, 0, 0, 0, 0)   ; Parse WinBatch command line.
arrParam = udfStrParseToArray (strString)
GoSub DisplayResult

intTest = 2
strString = '11 222 "text with blanks" 333' ; 4 parameters.
arrParam = udfStrParseToArray (strString)
GoSub DisplayResult

intTest = 3
strString = "11 222 'text with blanks' 333" ; 4 parameters.
arrParam = udfStrParseToArray (strString)
GoSub DisplayResult

intTest = 4
strString = "11 222 `text with blanks` 333" ; 4 parameters.
arrParam = udfStrParseToArray (strString)
GoSub DisplayResult

intTest = 5
strString = "11 222 ´text with blanks´ 333" ; 6 parameters.
arrParam = udfStrParseToArray (strString)
GoSub DisplayResult

intTest = 6
strString = "11 222 text with blanks 333"   ; 6 parameters.
arrParam = udfStrParseToArray (strString)
GoSub DisplayResult

Exit
;------------------------------------------------------------------------------------------------------------------------------------------
:DisplayResult
intarrParamDims = ArrInfo (arrParam, 0) ; Number of dimensions in the array.
intarrParamDim1 = ArrInfo (arrParam, 1) ; Number of elements in dimension-1.
strMsgText = "Example " : intTest : @LF : @LF : "strString = " : strString : @LF : @LF : "ParamDims = " : intarrParamDims : @LF : "ParamDim1 = " : intarrParamDim1 : @LF : @LF

strParam = "[No array elements]"
If intarrParamDim1
   intMax = intarrParamDim1 - 1
   strParam = ""
   For intElem = 0 To intMax
      strParam = strParam : arrParam [intElem] : @LF
   Next
EndIf

IntControl (28, 1, 0, 0, 0) ; Selects system font used in list boxes. 1=fixed pitch font.
IntControl (63, 250, 250, 750, 750) ; Sets coordinates for AskItemList window.
AskItemlist (strMsgTitle, strMsgText : strParam, @LF, @UNSORTED, @SINGLE)

Return ; from GoSub DisplayResult
;------------------------------------------------------------------------------------------------------------------------------------------
; Run ("Drive:\Folder\udfGetParamArray().wbt", '11 222 "text with blanks" 333') ; Here are 5 parameters.
;------------------------------------------------------------------------------------------------------------------------------------------