Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: intcontrol(1006 intcontrol (1006 255 character command line
Although in the following script, param0 reports the limited number of parameters that fit into the 255 character command line limitation, the variable paramString actually returns all of your parameters.
The following scripts displays all the parameters, and then parses them out:
paramString = IntControl(1006,0,0,0,0) Message("Parameters: %param0%", paramstring) paramstring=strreplace(paramstring," ",@tab) paramcount=itemcount(paramstring,@tab) If param0<>0 For i=1 to paramcount param%i%= ItemExtract(i, paramstring, @tab) next Endif ;Next line not needed... You can display what you've got with the following: Askitemlist("Parameters: %paramcount%", paramstring, @tab, @unsorted, @single)An interesting aspect to note is that while Winbatch will only send up to 9 parameters into param 1 - 9 (and will not create param10, param11, etc.), param0 is still the number of parameters, even if greater than 9, so the following statement works:
Terminate(param0 > 9,"number of parms is too many", "%param0% parameters were given")Here's another way to parse the parameters out of the IntControl(1006...) function:
;--------------cut------------------------- paramString = IntControl(1006,0,0,0,0) Message("Parameters: %param0%", paramstring)The variable ParamString can be parsed the following way:
paramString = IntControl(1006,0,0,0,0) i = 1 ; counts words j = 1 ; counts parameters While @true ; loop through paramString par%j% = ItemExtract(i, paramString, " ") ;get a word If StrSub(par%j%,1,1) == `"` ;if a quotation mark begins the word While StrSub(par%j%,StrLen(par%j%),1) <> `"` ; loop until end of quotation i = i + 1 ;goto next word par%j% = StrCat(par%j%, " ", ItemExtract(i, paramString, " ")) ;and add word EndWhile par%j% = StrReplace(par%j%, `"`, ``) ;strip quotation marks from result Endif If j == param0 Then break ; when done parsing, break j = j + 1 ; goto next parameter i = i + 1 ; and next word EndWhile ; DoneIf you use param%j% instead of par%j%, the end result is to simply replace/create param10, param12, etc., as though there were no limit.
Here's a preface:
If for some reason you need more than a total of 9 parameters, refer to the attached file that contains a snippet of code that duplicates the rules used by ParseData() but handles as many parameters as your particular Windows platform will allow to fit on a single command line.
The attached file also has a text file that describes the rules used in the parsing of parameters and the usage of the different quotes and strings which contain a mix of different quoting characters.
ParseDataEx.wbt
Article ID: W13904
Filename: How to Pass More than 9 Parameters.txt
File Created: 2017:08:29:11:19:22
Last Updated: 2017:08:29:11:19:22