Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Document.Write question

Status
Not open for further replies.

Staticfactory

IS-IT--Management
Mar 1, 2005
79
CA
This is the first time I've tried to incorporate vbscript into a webpage (as a GUI of sorts) and I'm wondering why this simple code in the body of the document won't work?

Code:
<script type="text/vbscript">
	  
const forReading = 1
const forWriting = 2
const forAppending = 8
	  
Dim elem, iUpperBound, arrText(), fRead, fso
	  	  
iUpperBound = 0
		
set fso = CreateObject("Scripting.FileSystemObject")
set fRead = fso.OpenTextFile("SomeFile.txt", forReading)
		
While Not fRead.AtEndOfStream
		
     ReDim Preserve arrText(iUpperBound)
     arrText(UBound(arrText)) = tFileRead.ReadLine
     iUpperBound = iUpperBound + 1
			  
wend

fRead.close
	  
for each elem in arrText
	  	  
     document.write (elem)
		 		  
next

set fRead = Nothing
set fso = Nothing

</script>

I would imagine this is a simple question, but I'm not sure why it doesn't seem to be doing anything. Is there something about IE security settings that blocks FSO usage?
 
>[tt]arrText(UBound(arrText)) = tFileRead.ReadLine[/tt]
Q: tFileRead? what is it?
A: fRead.
 
A shorter way:
Set fRead = fso_OpenTextFile("SomeFile.txt", forReading)
document.write fRead.ReadAll
fRead.Close
Set fRead = Nothing

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Also you need full path, else it refers to fso's getfolder(".") which is usually not what you intend to use.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top