Jon Lau
|
| Posted: 04/30/2002, 9:20 AM |
|
I know this is no place to ask about ASP code.
But,
anyone knows how to read a text file using ASP code and substring the text
at certain interval fixed position of the text.
The text have rows/records of data with fixed column postion.
Regards,
Jon Lau
|
|
|
 |
Sixto Luis Santos
|
| Posted: 04/30/2002, 7:32 PM |
|
Hello,
To open the text file, use the FileSystemObject object:
<%
Set fs=CreateObject("Scripting.FileSystemObject")
Set fsText=fs.OpenTextFile(filename)
' Once open, use ReadLine to read from the file, one line at a time
' of course, you need to do this from the begining to the end of the file
' so we use a loop and check the state of the AtEndOfStream property
'
' ReadLine reads a whole line and increments the line position marker
While not fsText.AtEndOfStream
sLine=fsText.ReadLine
' Ok... sLine now holds the text line, we need to extract the column values
' and we can use the Mid function for this.
value1 = Mid(sLine, position, lenght)
' Do whatever you need to do with the values
' then continue with the next line
Wend
' It is always a good practice to clean after yourself
fsText.Close
Set fsText=Nothing
Set fs=Nothing
%>
Regards,
Sixto
"Jon Lau" <laujon@mbox2.singnet.com.sg> wrote in message
news:aamg8g$guv$1@news.codecharge.com...
> I know this is no place to ask about ASP code.
> But,
> anyone knows how to read a text file using ASP code and substring the text
> at certain interval fixed position of the text.
> The text have rows/records of data with fixed column postion.
>
> Regards,
>
> Jon Lau
>
>
>
>
|
|
|
 |
|