Text file as argument

Discussion in 'Scripting' started by Mark, Sep 12, 2003.

  1. Mark

    Mark Guest

    Newbie question,

    I am running Win NT SP6 and WSH v5.6.

    The script is as follows: test.vbs

    Const INPUT_FILE_NAME = Wscript.Arguments(0)
    Const FOR_READING = 1

    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objFile = objFSO.OpenTextFile(INPUT_FILE_NAME,
    strComputers = objFile.ReadAll

    arrComputers = Split(strComputers, vbCrLf)

    For x = 0 TO UBound(arrComputer)
    Wscript.Echo arrComputer(x)

    When I drag a text file onto the icon for my script I get
    the following error:

    Line 1
    Char 45
    Error Expected literal constant

    Any ideas?

    Mark, Sep 12, 2003
    1. Advertisements

  2. Mark

    Tom Lavedas Guest

    A CONST declaration wants a LITERAL string, just as the
    error message says. It cannot accept an object's
    property. Just a literal number or string (characters
    between quote marks) - no variables, no functions and no

    Remove the CONST declaration from the first line and it
    should work as expected.

    Tom Lavedas
    Tom Lavedas, Sep 12, 2003
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.