Showing posts with label ASP. Show all posts
Showing posts with label ASP. Show all posts

Thursday, July 2, 2009

Showing Page Load Time: Asp Classic/VBScript


Page Load Time: Asp Classic/VBScript



Shows the script page load time at the bottom of each ASP page.



At the header of the Page:

<%

dim starttime

startrime = Timer

%>



At the footer of the page:

<%

dim endtime,timetaken

endtime = Timer

timetaken = FormatNumber(endtime - starttime,4)

response.write "page load time: " & timetaken & " seconds"

%>

Sunday, March 22, 2009

Classic ASP: dump text file contents into array

The code below is reading text file and putting its lines into array.
After the code is executed, each item of the array will be one
line of the text file.


<%

Function ReadTextFile(strFilePath)

 Dim objFSO, objFile, strAllFile

 Set objFSO = Server.CreateObject("Scripting.FileSystemObject")

 Set objFile = objFSO.OpenTextFile(strFilePath)

 strAllFile = ""

 If Not(objFile.AtEndOfStream) Then

  strAllFile = objFile.ReadAll

 End If

 objFile.Close

 Set objFile = Nothing

 Set objFSO = Nothing

 

 strAllFile = Replace(strAllFile, Chr(13)&Chr(10), Chr(13))

 strAllFile = Replace(strAllFile, Chr(10)&Chr(13), Chr(13))

 ReadTextFile = Split(strAllFile, Chr(13))

End Function



'usage

Const FILE_NAME="myfile.txt"

Dim arrLines, x, curLine

Response.Write("reading file: " & FILE_NAME & "...<br />")

arrLines = ReadTextFile(Server.MapPath(FILE_NAME))

Response.Write("amount of lines: " & (UBound(arrLines)+1) & "<br />")

Response.Write("file contents:<hr />")

For x=0 To UBound(arrLines)

 curLine = arrLines(x)

 Response.Write("Line #" & (x+1) & " " & Server.HTMLEncode(curLine) & "<br />")

Next

Response.Write("<hr />")

%>



Source: http://forums.aspfree.com/

Tuesday, March 10, 2009

Basic ASP XML Output

ASP XML Output

<%
response.contentType="text/xml"
response.write("<?xml version='1.0' encoding='ISO-8859-1'?>")
response.write("<note>mooage</note>")
%>

Tuesday, March 3, 2009

Including a file in ASP

I always forget the exact statement for this for some reason, ill probably remember now ;)

<!--#include file="wisdom.inc"-->

http://www.w3schools.com/asp/asp_incfiles.asp

Thursday, February 26, 2009

ASP RSS Retrieval

Grabs a feed and displays it.

'::::::::::::::::::::::::::::::::::::::::::::::::::
':::: rss.asp ::::::::::::::::::::::::::::::::::
'::::::::::::::::::::::::::::::::::::::::::::::::::

<%
Call getRSS(10)
Sub getRSS(howManyResults)
myRSSfile = "http://rss.news.yahoo.com/rss/tech"
Set xmlHttp = Server.CreateObject("MSXML2.XMLHTTP.4.0")
xmlHttp.Open "Get", myRSSfile, false
xmlHttp.Send()
myXML = xmlHttp.ResponseText

Set xmlResponse = Server.CreateObject("MSXML2.DomDocument.4.0")
xmlResponse.async = false
xmlResponse.LoadXml(myXML)
Set xmlHttp = Nothing

Set objLst = xmlResponse.getElementsByTagName("item")
Set xmlResponse = Nothing
intNoOfHeadlines = objLst.length -1
For i = 0 To (intNoOfHeadlines)
Set objHdl = objLst.item(i)
for each child in objHdl.childNodes
Select case lcase(child.nodeName)

case "title"
title = child.text
case "link"
link = child.text
case "description"
description = child.text
'You can also use the following: author,category,comments,enclosure,guid,pubDate,source

End Select

next
kk = kk+1
if kk < howManyresults+1 then
Response.Write "<br /><a href=""" & link & """>" & title & "</a> <br /> " & description & "<br>"
end if
Next

End Sub

%>

'::::::::::::::::::::::::::::::::::::::::::::::::::
'::::::::::::::::::::::::::::::::::::::::::::::::::