Home-->
Articles -->
Site Tools
The quote of the day in ASP

Post By suteng on 2008-9-26 15:51:03 [Reads:302]
The quote of the day in ASP to generate the display of an uncertain text in one ASP page, the operation takes place in two simple stages.
1. One creates a file text (that one goes in our example to call citations.txt) and that one is going to place, for example, in a subdirectory titled quotes.
This file will include a quote by line. What comes back to say that every return to the line will be interpreted as the end of a quote.
Let's write down therefore in this file 5 quotes on a trial basis:
Go so much the crock to water that at the end she/it breaks herself/itself (The Fountain) All flattering lives at the expense of the one that listens it (The Fountain) If the women were good, God would have an of it (Coluche) The idiots, that dares all. It is besides it that one recognizes them (Audiard) Nothing is more similar to the identical that what is similar to the same (Pierre Dac)
Then, in the ASP page that is going to be assigned to display the uncertain quote, let's insert the following code.
In headline of the page before the code HTML of preference:
<% Set objFile = Server.CreateObject ("Scripting.FileSystemObject") Set objStream = objFile.OpenTextFile(Server.MapPath (" / quotes") & "\ citations.txt")
Randomize Timer intCit = Int(Rnd * 5) Heart i = 0 to intCit objStream.SkipLine Next
strCit = objStream.ReadLine
objStream.Close Set objStream = Nothing Set objFile = Nothing% >
then right side up where the quote must be displayed:
<% = strCit% >
To note that the number 5 in the line intCit = Int(Rnd * 5) corresponds to the total number of quotes contained in the file text. Also specify that more your file will include quotes, and more the effect will be spectacular. In the practice, for a real efficiency of the thing, a minimum of 50 quotes is desirable.