dcsimg
Login | Register   
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Language: SQL
Expertise: Intermediate
Dec 15, 2003

WEBINAR:

On-Demand

Application Security Testing: An Integral Part of DevOps


Display a Partial Text File Using FSO

This script reads specific lines of text from any text file and then stores the lines in an array that you can assign to a variable for data display.

<%
Const ForReading = 1

' The following line numbers will be read into the array
Dim myArr(4)
myArr(0)="10"
myArr(1)="12"
myArr(2)="15"
myArr(3)="17"

' Counter used for array increment
i = 0

' Create FSO Object & Set File to Read
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.GetFile("C:\inetpub\wwwroot\Readme.Txt")

' Open file for reading.
Set objTextFile = objFile.OpenAsTextStream(ForReading)

' Loop Through TEXT File and Get Text to Display
Do While objTextFile.AtEndOfStream <> True
    CurrLine = objTextFile.Line
    If Cstr(CurrLine) = Cstr(myArr(i)) Then
	myArr(i)=UCASE(objTextFile.ReadLine)
        i = i + 1
    Else
        CurrLine = objTextFile.ReadLine
    End If
Loop

' Set variables
Line10 = myArr(0)
Line12 = myArr(1)
Line15 = myArr(2)
Line17 = myArr(3)

' Close & Destroy
objTextFile.Close
Set objFSO = Nothing
Set objFile = Nothing

' Display Data
Response.Write "Line 10 reads: " & Line10
Response.Write "Line 12 reads: " & Line12
Response.Write "Line 15 reads: " & Line15
Response.Write "Line 17 reads: " & Line17
%>
DevX Staff
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
×
We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.
Thanks for your registration, follow us on our social networks to keep up-to-date