Re: VBScript error 800A0401 'Expected end of statement' on 'Open ... For Input ...' by McKirahan
McKirahan
Mon May 24 09:04:44 CDT 2004
"Alpsummit" <pberod@groupemutuel.ch> wrote in message
news:58b77371.0405240556.34254983@posting.google.com...
> Hi,
>
> I tried this code :
>
> FileName = "C:\temp\SC.csv"
> Open FileName For Input as #1
> Do Until EOF #1
> Input #1, datastring
> Loop
> Close #1
>
> and I get this message :
>
> Windows Script Host
> Error: Expected end of statement
> Code: 800A0401
> Source: Microsoft VBScript compilation error
>
> I can't find out where I made a mistake...
>
> Can anyone help me ?
>
> Thanks
You're use QBasic not VBScript syntax.
You need to use the FileSystemObject.
Option Explicit
Const cOTF = "C:\temp\SC.csv"
Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim objOTF
Set objOTF = objFSO.OpenTextFile(cOTF,1)
If Not objOTF.AtEndOfStream Then
WScript.Echo objOTF.ReadLine()
End If
Set objOTF = Nothing
Set objFSO = Nothing
This just displays each line in the file.
Run under WScript it will "popup" each record.
Run under CScript it will list each record in a window.