PDA

View Full Version : Dynamic pricing



tekken
January 30th, 2004, 07:52 AM
Could someone please help me with an ASP problem. I want to havethe drug prices in a single textfile 1/line and then fetch the correct line where I want the price.


I found the below code, andit works for fething the first line but how do I fetch say 3 lines? E.x line nr 20, 32 and 9?


code
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">


&lt;html&gt;
&lt;body&gt;
&lt;p&gt;This is the first line of the text file:&lt;/p&gt;

&lt;%
Set fs=Server.CreateObject("Scripting.FileSystemObject")

Set f=fs.OpenTextFile(Server.MapPath("testread.txt"), 1)
Response.Write(f.ReadLine)
f.Close

Set f=Nothing
Set fs=Nothing
%&gt;

&lt;/body&gt;
&lt;/html&gt;
</BLOCKQUOTE>

~Zoe
February 3rd, 2004, 12:59 PM
Rinse and Repeat


Response.Write(f.ReadLine)
Response.Write(f.ReadLine) ' will print the second line
Response.Write(f.ReadLine) ' will print the next line


Or stick it into a variable,
strPrice = f.ReadLine

MedsDirect
February 3rd, 2004, 01:38 PM
Also, if you can edit the source file, you could set it up so that each line is a string bound to a var named ln1, ln2, ln3 etc. Then include the txt file as asp and just call the line you need.


If you cant change the text files, you can loop the lines into an array


Dim fileEnd As String = "start"
Dim Line() As Array
Dim i As Integer = 1


Do While Not fileEnd = ""
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">


Line(i) = f.ReadLine
fileEnd = Line(i)
i = i + 1</BLOCKQUOTE>
Loop
---
Then you can just use Line(20), Line(32), Line(9) etc as needed.
You could also bind this to an application variable so that it doesnt run as often.