Wilson WindowWare Tech Support

WinBatch WinBatch+Compiler WebBatch
Home | Tech Database | Tech BBS | White Papers | Purchase


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 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