Question

I'm having some trouble figuring out what's wrong with my VBScript code as it's giving me

Script Engine Error:62:Input past end of file

when i'm trying to run

Function FSORead(ini,Section,Key,defval)
Set FSO = CreateObject("Scripting.FileSystemObject")
Set File =  FSO.OpenTextFile("C:\Documents and Settings\ndtm\Application Data\IceChat\Scripts\"+ini)
keysearch = False
Do Until File.AtEndOfStream
    if keysearch = False then
        if File.ReadLine = "["&Section&"]" then
            keysearch = True
        end if
    else
        if Key = Mid(File.ReadLine,1,instr(File.ReadLine,"=")-1) then
            FSORead = Mid(File.ReadLine,len(Key)+1)
        end if
        if Mid(File.ReadLine,1,1) = "[" then
            FSORead = defval
        end if
    end if
Loop
FSORead = defval
End Function

And the File i'm calling does exist and does contain stuff like

[section1]
var1=randomvalue
[section2]
var=someothervalue

I have been trying different things but it's not working so i came here to see if someone could help me find what's wrong and how to fix it

Oh and this is the Sub calling it, it's made for a bot in a IRC network and the "SendCommand" basically allows you to execute non-script commands within the script itself

Sub FSOTest()
    SendCommand "/msg #ndtm "&FSORead("http.ini","qtserver","survival","")
End Sub
Was it helpful?

Solution

Your

if Key = Mid(File.ReadLine,1,instr(File.ReadLine,"=")-1) then

tries to read two lines from the file. You need a variable that can be send to Mid and Instr.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top