WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Variables and Parameters

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

How to Pass an Unknown Number of Parameters

Keywords:   parameters param0 

Question:

The question is how do I pass an unknown number of parameters to a program?

Answer:

Here's how:
 ; example of passing a program name and up to 8 cmd-line parameters to a WBT
 If param0 == 0 Then Exit            ; if called with no parameters
 ;If param0 > 9 Then param0 = 9       ; WinBatch 2003F and older only supports up to 'param9'

 params = ""                                   ; initialize param string
 For i = 2 To param0                           ; for param2 through last param
    params = StrCat(params, param%i%)                 ; concatenate this to end of param string
    If i < param0 Then params = StrCat(params, " ")   ; add space if not last param
 Next

 RunZoom(param1, params)         ; run the program (passed as 'param1')

Article ID:   W13911
Filename:   Pass Unknown Number of Parameters.txt
File Created: 2003:04:24:12:28:02
Last Updated: 2003:04:24:12:28:02