<% ' News 1.0 : news.asp ' ' Display the news list by categories. ' ' 1.0.0 (09/01/2002) ' José N. Dévora Espino. ' ' Copyright © 1999-2004 Infolink Aplicaciones, S.A. de C.V. ' All rights reserved ' Derechos de Autor © 1999-2004 Infolink Aplicaciones, S.A. de C.V. ' Derechos Reservados. %> <%Dim sCurrentPage sCurrentPage="news" page = "Company News" %>


<% iCurrentPage = CStr(DefaultRequest("page", "1")) recordPosition = 1 Dim sCurrentCat, sOldCat, iNumber, bCloseQuote sSQL = "SELECT * FROM News WHERE " _ & "(#" & Date & "# BETWEEN PublicationDate AND (PublicationDate + ActiveDays)) " _ & "OR (ActiveDays=0 AND PublicationDate <= #" & Date & "#) ORDER BY Category, OrderShown" Set rsData = conDB.Execute(sSQL) ' Get total number of News iNewsCount = conDB.Execute("SELECT COUNT(*) FROM News WHERE " _ & "(#" & Date & "# BETWEEN PublicationDate AND (PublicationDate + ActiveDays)) " _ & "OR (ActiveDays=0 AND PublicationDate <= #" & Date & "#)" ).Fields(0) If IsRSEmpty(rsData) Then%>

<%=smNoNews%>

<%Else With rsData sCurrentCat="" sOldCat = "" bCloseQuote = False While Not .EOF If (recordPosition > ( (iCurrentPage-1)*gcNewsPerPage )) And ( recordPosition < ( iCurrentPage*gcNewsPerPage +1 ) ) Then ' Set the new category to check if the next is the same category If IsNull(.Fields("category")) Then sCurrentCat = "" Else sCurrentCat = .Fields( "category" ) End If If sCurrentCat <> sOldCat Then If bCloseQuote Then Response.Write ""%> <%=.Fields("Category")%>
<%End If%> "><%=.Fields("Headline")%>
<% End If recordPosition = recordPosition + 1 sOldCat = sCurrentCat bCloseQuote = True .MoveNext Wend If bCloseQuote Then Response.Write "
" .Close End With End If If iCurrentPage >1 Then %> <%=smPrev%> | <% End If If (iCurrentPage-1.0) < (FLOOR( iNewsCount / gcNewsPerPage )) Then If (iCurrentPage+0.0) <> ( (iNewsCount / gcNewsPerPage)+0.0 ) Then %> <%=smNext%> <%End If End If ' Delete old records Randomize iNumber = Int( 10 * Rnd ) + 1 If iNumber <= 2 Then conDB.Execute "DELETE FROM News WHERE '" & Date & "' > (PublicationDate + ActiveDays) AND AutoRemovible=1" ' Returns a value even if the variable in the request is not defined Function DefaultRequest(ByVal sRequestVariable, vDefaultValue) If IsRequestDefined(sRequestVariable) Then DefaultRequest = Request(sRequestVariable) Else DefaultRequest = vDefaultValue End If End Function ' Tells if a variable was passed or not Function IsRequestDefined(sVarName) IsRequestDefined = Len(Request(sVarName)) > 0 End Function Function Floor(byval n) Dim iTmp, bErr on error resume next n = cdbl(n) if err then bErr = true on error goto 0 if bErr then Err.Raise 5000, "Floor Function", _ "Input must be convertible to a sub-type of double" 'Round() rounds up iTmp = Round(n) 'test rounded value against the non rounded value 'if greater, subtract 1 if iTmp > n then iTmp = iTmp - 1 Floor = cInt(iTmp) End Function %>