Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP VBScript
Pl review following code-
Function FileProperties( sFileName, sLength, sDateTime, sAttr)
    dim oFS, oFile
    Set oFS = Server.CreateObject("Scripting.FileSystemObject")
 
    if ( oFS.FileExists( sFileName ) ) then
        set oFile = oFS.GetFile( sFileName )
        sLength = oFile.size
        sDateTime = oFile.DateLastModified
        sAttr = oFile.Attributes
 
        set oFile = Nothing
        FileProperties = true
    else
        ' might be a folder
        if ( oFS.FolderExists( sFileName ) ) then
            set oFile = oFS.GetFolder( sFileName )
 
            sLength =  oFile.size 
            sDateTime = oFile.DateLastModified
            sAttr = oFile.Attributes
 
            set oFile = Nothing
            FileProperties = true
        else
            FileProperties = false
        end if
    end if
 
    set oFS = Nothing
end Function
 
Function FileReadLine( oFile, sLineOfFile )
    if not oFile.AtEndOfStream then
        sLineOfFile = oFile.ReadLine()
        FileReadLine = true
    else
        FileReadLine = false
    end if
 
end Function
Using above to two function, I want to read content from file,
so I wrote following script -
Dim fs1, fs2, fs3
 
sFileName = server.mappath("/db/remoteinfo.txt")
call FileProperties( sFileName, sLength, sDateTime, sAttr)
 
response.write "Length -  " & sLength 
 
call FileReadLine(oFile, sLineOfFile)
Here I get error message :
Microsoft VBScript runtime error '800a01a8'
 
Object required: 'oFile'
 
Please help me as it is very urgent.
 

Thanks in advance....
Posted 31-Jul-12 21:35pm
Edited 31-Jul-12 22:02pm
v2
Comments
Christian Graus at 1-Aug-12 2:37am
   
Don't tell us it's urgent. We are not being paid and won't answer quicker because you told us to.
techfortune at 1-Aug-12 2:42am
   
Sorry and understand, will keep your suggestion in mind while posting next future questions..

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You have not posted anywhere that you call FileReadLine, but I am guessing that you didn't pass it in, or it's Nothing.
 
ASP is a nightmare, I would run from this project as fast as you can.
  Permalink  
Comments
techfortune at 1-Aug-12 2:40am
   
Thanks for immediate response, but I have used FileReadLine function -
 
Dim fs1, fs2, fs3

sFileName = server.mappath("/db/remoteinfo.txt")
call FileProperties( sFileName, sLength, sDateTime, sAttr)
 
call FileReadLine(oFile, sLineOfFile)
Christian Graus at 1-Aug-12 2:41am
   
OK - as you posted that out of all context, I can't see what oFile would be at that point in time, but your error makes me think it is 'nothing'. If you were using a real web development platform, you could debug it. As it stands, I'd add code to do a response.write to tell you the state of the object.
techfortune at 1-Aug-12 2:49am
   
Thanks again!
 
oFile is declared in FileProperties, and I expect it be passed as reference in FileReadLine function as it is.
 
Because if I use following statement, it works
response.write " Length - " & sLength & ", Attribute - " & sAttr & ", Date - " & sDateTime
 
But when oFile return "NULL"
techfortune at 1-Aug-12 2:56am
   
Can you suggest any sort of clue to debug this code ?
Christian Graus at 1-Aug-12 3:43am
   
I reiterate, asp is a nightmare. But, you can write code that uses response.write to emit text based on things like the state of oFile, to tell you what is going wrong.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 325
1 DamithSL 265
2 CPallini 235
3 Sergey Alexandrovich Kryukov 229
4 Maciej Los 190
0 OriginalGriff 5,455
1 DamithSL 4,422
2 Maciej Los 3,860
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,010


Advertise | Privacy | Mobile
Web04 | 2.8.141216.1 | Last Updated 1 Aug 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100