Board index » Visual Studio » Input past end of file ???

Input past end of file ???

Visual Studio145
'***************** MAIN CODE BODY ********************

'************** declare page level variables ************



Const ForReading = 1

dim objFSO, objFile, strHTML, strPath



If Request.ServerVariables("REQUEST_METHOD") = "POST" Then

strPath = "c:\test.txt" 'request("dropdown2")

set objFSO = CreateObject("Scripting.FileSystemObject")

set objFile = objFSO.OpenTextFile(strPath, ForReading)

strHTML = objFile.Readline

response.Write("..." & strHTML & "...")

End If

'***************** END BODY CODE ********************



"c:\test.txt"

=============

This is a Test Line 1

This is a Test Line 2

This is a Test Line 3

This is a Test Line 4

The end



'****************************************************



Hi there,



I am at a lost here. I have done numerous research and it looks like relatively straight forward to open a text file and read from it.



I kept getting this error :



Microsoft VBScript runtime error '800a003e'

Input past end of file

listings.asp, line 42 ===>strHTML = objFile.Readline



Does anyone have any suggestion where did it go wrong ?? Appreciate any help.


-
 

Re:Input past end of file ???

Replace;



Quote
strHTML = objFile.Readline



With



Do While Not objFile.AtEndOfStream

strHTML = objFile.ReadLine & "<br>"

Loop

objFile.Close



Response.Write strHTML



--



Regards



Steven Burn

Ur I.T. Mate Group

www.it-mate.co.uk



Keeping it FREE!





"ym" <ym@discussions.microsoft.com>wrote in message

Quote
'***************** MAIN CODE BODY ********************

'************** declare page level variables ************



Const ForReading = 1

dim objFSO, objFile, strHTML, strPath



If Request.ServerVariables("REQUEST_METHOD") = "POST" Then

strPath = "c:\test.txt" 'request("dropdown2")

set objFSO = CreateObject("Scripting.FileSystemObject")

set objFile = objFSO.OpenTextFile(strPath, ForReading)

strHTML = objFile.Readline

response.Write("..." & strHTML & "...")

End If

'***************** END BODY CODE ********************



"c:\test.txt"

=============

This is a Test Line 1

This is a Test Line 2

This is a Test Line 3

This is a Test Line 4

The end



'****************************************************



Hi there,



I am at a lost here. I have done numerous research and it looks like

relatively straight forward to open a text file and read from it.



I kept getting this error :



Microsoft VBScript runtime error '800a003e'

Input past end of file

listings.asp, line 42 ===>strHTML = objFile.Readline



Does anyone have any suggestion where did it go wrong ?? Appreciate any

help.









-

Re:Input past end of file ???

Hi Steve,



Thank you. I don't get this Input past end of file error now. I think I was getting this error because it has to do with how I specify where this "c:\test.txt" test file is located.



the OpenTextFile syntax requires a full path and filename.



Full physical path where my asp file resides :

c:\\Web\Virtual Websites\biz\bh_TEST\test.asp



Logical web site path : 192.168.1.237/bh_TEST/test.asp">192.168.1.237/bh_TEST/test.asp



When I declare "c:\test.txt" as path for the OpenTextFile - where should this file physically resides in 1) c:\\test.txt or 2) c:\\web\Virtual Websites\biz ???



To test, I have the "test.txt" in -

c:\\web\Virtual Websites\test.txt

c:\\web\Virtual Websites\biz\test.txt

c:\\web\Virtual Websites\biz\bh_TEST\test.txt



My results after executing codes return "".



Thank you.







"Steven Burn" wrote:



Quote
Replace;



>strHTML = objFile.Readline



With



Do While Not objFile.AtEndOfStream

strHTML = objFile.ReadLine & "<br>"

Loop

objFile.Close



Response.Write strHTML



--



Regards



Steven Burn

Ur I.T. Mate Group

www.it-mate.co.uk



Keeping it FREE!





"ym" <ym@discussions.microsoft.com>wrote in message

news:997AD480-79AA-45FE-86D3-036BA4EC5FB2@microsoft.com...

>'***************** MAIN CODE BODY ********************

>'************** declare page level variables ************

>

>Const ForReading = 1

>dim objFSO, objFile, strHTML, strPath

>

>If Request.ServerVariables("REQUEST_METHOD") = "POST" Then

>strPath = "c:\test.txt" 'request("dropdown2")

>set objFSO = CreateObject("Scripting.FileSystemObject")

>set objFile = objFSO.OpenTextFile(strPath, ForReading)

>strHTML = objFile.Readline

>response.Write("..." & strHTML & "...")

>End If

>'***************** END BODY CODE ********************

>

>"c:\test.txt"

>=============

>This is a Test Line 1

>This is a Test Line 2

>This is a Test Line 3

>This is a Test Line 4

>The end

>

>'****************************************************

>

>Hi there,

>

>I am at a lost here. I have done numerous research and it looks like

relatively straight forward to open a text file and read from it.

>

>I kept getting this error :

>

>Microsoft VBScript runtime error '800a003e'

>Input past end of file

>listings.asp, line 42 ===>strHTML = objFile.Readline

>

>Does anyone have any suggestion where did it go wrong ?? Appreciate any

help.

>

>







-

Re:Input past end of file ???

strPath = "c:\test.txt"



Should actually be;



strPath = Server.MapPath("c:\test.txt")



--



Regards



Steven Burn

Ur I.T. Mate Group

www.it-mate.co.uk



Keeping it FREE!





"ym" <ym@discussions.microsoft.com>wrote in message

Quote
Hi Steve,



Thank you. I don't get this Input past end of file error now. I think I

was getting this error because it has to do with how I specify where this

"c:\test.txt" test file is located.

Quote


the OpenTextFile syntax requires a full path and filename.



Full physical path where my asp file resides :

c:\\Web\Virtual Websites\biz\bh_TEST\test.asp



Logical web site path : 192.168.1.237/bh_TEST/test.asp">192.168.1.237/bh_TEST/test.asp



When I declare "c:\test.txt" as path for the OpenTextFile - where should

this file physically resides in 1) c:\\test.txt or 2) c:\\web\Virtual

Websites\biz ???

Quote


To test, I have the "test.txt" in -

c:\\web\Virtual Websites\test.txt

c:\\web\Virtual Websites\biz\test.txt

c:\\web\Virtual Websites\biz\bh_TEST\test.txt



My results after executing codes return "".



Thank you.







"Steven Burn" wrote:



>Replace;

>

>>strHTML = objFile.Readline

>

>With

>

>Do While Not objFile.AtEndOfStream

>strHTML = objFile.ReadLine & "<br>"

>Loop

>objFile.Close

>

>Response.Write strHTML

>

>--

>

>Regards

>

>Steven Burn

>Ur I.T. Mate Group

>www.it-mate.co.uk

>

>Keeping it FREE!

>

>

>"ym" <ym@discussions.microsoft.com>wrote in message

>news:997AD480-79AA-45FE-86D3-036BA4EC5FB2@microsoft.com...

>>'***************** MAIN CODE BODY ********************

>>'************** declare page level variables ************

>>

>>Const ForReading = 1

>>dim objFSO, objFile, strHTML, strPath

>>

>>If Request.ServerVariables("REQUEST_METHOD") = "POST" Then

>>strPath = "c:\test.txt" 'request("dropdown2")

>>set objFSO = CreateObject("Scripting.FileSystemObject")

>>set objFile = objFSO.OpenTextFile(strPath, ForReading)

>>strHTML = objFile.Readline

>>response.Write("..." & strHTML & "...")

>>End If

>>'***************** END BODY CODE ********************

>>

>>"c:\test.txt"

>>=============

>>This is a Test Line 1

>>This is a Test Line 2

>>This is a Test Line 3

>>This is a Test Line 4

>>The end

>>

>>'****************************************************

>>

>>Hi there,

>>

>>I am at a lost here. I have done numerous research and it looks like

>relatively straight forward to open a text file and read from it.

>>

>>I kept getting this error :

>>

>>Microsoft VBScript runtime error '800a003e'

>>Input past end of file

>>listings.asp, line 42 ===>strHTML = objFile.Readline

>>

>>Does anyone have any suggestion where did it go wrong ?? Appreciate

any

>help.

>>

>>

>

>

>





-

Re:Input past end of file ???

Your welcome :o)



--



Regards



Steven Burn

Ur I.T. Mate Group

www.it-mate.co.uk



Keeping it FREE!





"ym" <ym@discussions.microsoft.com>wrote in message

Quote
Thank you and I appreciate your help...I can read the file now :)



"Steven Burn" wrote:



>strPath = "c:\test.txt"

>

>Should actually be;

>

>strPath = Server.MapPath("c:\test.txt")

>

>--

>

>Regards

>

>Steven Burn

>Ur I.T. Mate Group

>www.it-mate.co.uk

>

>Keeping it FREE!

>

>

>"ym" <ym@discussions.microsoft.com>wrote in message

>news:4F95D48D-D894-459D-8BF2-7E9FEAE45EEA@microsoft.com...

>>Hi Steve,

>>

>>Thank you. I don't get this Input past end of file error now. I

think I

>was getting this error because it has to do with how I specify where

this

>"c:\test.txt" test file is located.

>>

>>the OpenTextFile syntax requires a full path and filename.

>>

>>Full physical path where my asp file resides :

>>c:\\Web\Virtual Websites\biz\bh_TEST\test.asp

>>

>>Logical web site path : 192.168.1.237/bh_TEST/test.asp">192.168.1.237/bh_TEST/test.asp

>>

>>When I declare "c:\test.txt" as path for the OpenTextFile - where

should

>this file physically resides in 1) c:\\test.txt or 2)

c:\\web\Virtual

>Websites\biz ???

>>

>>To test, I have the "test.txt" in -

>>c:\\web\Virtual Websites\test.txt

>>c:\\web\Virtual Websites\biz\test.txt

>>c:\\web\Virtual Websites\biz\bh_TEST\test.txt

>>

>>My results after executing codes return "".

>>

>>Thank you.

>>

>>

>>

>>"Steven Burn" wrote:

>>

>>>Replace;

>>>

>>>>strHTML = objFile.Readline

>>>

>>>With

>>>

>>>Do While Not objFile.AtEndOfStream

>>>strHTML = objFile.ReadLine & "<br>"

>>>Loop

>>>objFile.Close

>>>

>>>Response.Write strHTML

>>>

>>>--

>>>

>>>Regards

>>>

>>>Steven Burn

>>>Ur I.T. Mate Group

>>>www.it-mate.co.uk

>>>

>>>Keeping it FREE!

>>>

>>>

>>>"ym" <ym@discussions.microsoft.com>wrote in message

>>>news:997AD480-79AA-45FE-86D3-036BA4EC5FB2@microsoft.com...

>>>>'***************** MAIN CODE BODY ********************

>>>>'************** declare page level variables ************

>>>>

>>>>Const ForReading = 1

>>>>dim objFSO, objFile, strHTML, strPath

>>>>

>>>>If Request.ServerVariables("REQUEST_METHOD") = "POST" Then

>>>>strPath = "c:\test.txt" 'request("dropdown2")

>>>>set objFSO = CreateObject("Scripting.FileSystemObject")

>>>>set objFile = objFSO.OpenTextFile(strPath, ForReading)

>>>>strHTML = objFile.Readline

>>>>response.Write("..." & strHTML & "...")

>>>>End If

>>>>'***************** END BODY CODE ********************

>>>>

>>>>"c:\test.txt"

>>>>=============

>>>>This is a Test Line 1

>>>>This is a Test Line 2

>>>>This is a Test Line 3

>>>>This is a Test Line 4

>>>>The end

>>>>

>>>>'****************************************************

>>>>

>>>>Hi there,

>>>>

>>>>I am at a lost here. I have done numerous research and it looks

like

>>>relatively straight forward to open a text file and read from it.

>>>>

>>>>I kept getting this error :

>>>>

>>>>Microsoft VBScript runtime error '800a003e'

>>>>Input past end of file

>>>>listings.asp, line 42 ===>strHTML = objFile.Readline

>>>>

>>>>Does anyone have any suggestion where did it go wrong ??

Appreciate

>any

>>>help.

>>>>

>>>>

>>>

>>>

>>>

>

>

>





-