vbscriptsapi

How can I read all arguments with the VBS-SAPI-VOICE?


I want to create a program, that automaticly reads all start-arguments. This is what I end with after some hours of researching and debugging but it still not working. (I'm not very experienced in VBScript.) The Error Message is something like "Instruction expected" or "statement expected" I dont know whats the right translation.(I use the German Version. The original Errormessage is: "Anweisung erwartet")

Private Sub Say()
Set VOICE = createobject("sapi.spvoice")
Set Args = WScript.Arguments
Count = 0
While(count > Args.Count)
    VOICE.speak(WScript.Arguments(count))
    count = count + 1
End While
End Sub

Say()

Have someone an idea? I hope you understood what I mean. (My English is awful)


Solution

  • Refer to this you can write something like that :

    Set VOICE = createobject("sapi.spvoice")
    ' Store the arguments in a variable:
    Set objArgs = Wscript.Arguments
    If objArgs.Count = 0 Then 
        Wscript.Echo "Missing parameters"
        VOICE.Speak "Missing parameters"
    End If
    
    ' Display all command-line arguments
    For Each strArg in objArgs
      WScript.Echo strArg
      VOICE.Speak strArg
    Next