<% Option Explicit response.buffer = true %> Acronyms
CISR > Resource Library>
Acronyms

<% dim admin, Words Words = request.querystring("words") %> Search | Browse<% if Session("LOGGEDIN") then %> <% end if %> <% dim tempString, sql, stringArray, i sql = "SELECT * FROM Master WHERE " tempString = request.querystring("string") stringArray = split(tempString," ") if words = "AND" then sql = sql & "ID LIKE '%" for i=0 to UBOUND(stringArray) sql = sql & stringArray(i) if i <> UBOUND(stringArray) then sql = sql & " " next sql = sql & "%' OR Acronym LIKE '%" for i=0 to UBOUND(stringArray) sql = sql & stringArray(i) if i <> UBOUND(stringArray) then sql = sql & " " next sql = sql & "%' OR Definition LIKE '%" for i=0 to UBOUND(stringArray) sql = sql & stringArray(i) if i <> UBOUND(stringArray) then sql = sql & " " next sql = sql & "%'" else for i=0 to UBOUND(stringArray) sql = sql & "ID LIKE '" & stringArray(i) & "' OR " sql = sql & "Acronym LIKE '%" & stringArray(i) & "%' OR " sql = sql & "Definition LIKE '%" & stringArray(i) & "%' " if NOT i = UBOUND(stringArray) then sql = sql & " " & Words & " " end if if i <> UBOUND(stringArray) then sql = sql & "OR " next end if sql = sql & " ORDER BY Acronym" const connectionStr = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=d:\inetpub\databases\acronyms.mdb" dim conn Set conn = Server.CreateObject("ADODB.Connection") conn.Open connectionStr dim rs set rs=Server.CreateObject("ADODB.RecordSet") rs.Open sql, conn, 1, 2 %>
<% '-------------------------------Start of Bookmarks---------------------------------------- dim intCol, intRow, Array, length, switch, reBold, wordstohighlight dim x, y, temp, temp2, z 'These variables are used only to create the bookmark links at the top of the list. There is 'another set after this section to create the actual list of items. dim b, c, bookmark, bookmark2 switch = false Array = rs.GetRows intCol = 2 intRow = rs.RecordCount intRow = intRow-1 %>
Index: <% for b=0 to intRow 'This IF section is testing the first letter of the acronym in the current and next record 'to determine if the length changes so it can indicate to write the bookmark bookmark (as in 'not bookmark2). if NOT b = intRow then length = len(Array(1,b)) - (len(Array(1,b))-1) bookmark = left(Array(1,b),length) c=b+1 length = len(Array(1,c)) - (len(Array(1,c))-1) bookmark2 = left(Array(1,c),length) 'Actually comparing the records and the setting the switch variable. If it is true then 'the last if/then in this section writes out the bookmark. if bookmark < bookmark2 then switch = true end if else temp = "" end if 'Writes out the header for the first level break for the beginning of the table if switch then response.write " " & bookmark2 & " " switch = false end if next response.write "
" '-------------------------------End of Bookmarks---------------------------------------- '-------------------------------Start Writing List---------------------------------------- %>
Total Records: <%=rs.recordcount%>

#
Acronym
Definition
<% rs.movefirst if rs.BOF And rs.EOF Then response.write "No Items Found" else wordstohighlight= stringArray Set reBold= New RegExp reBold.Pattern = "(" & JOIN(wordstohighlight, "|") & ")" reBold.IgnoreCase = True reBold.Global = True Array = rs.GetRows intCol = 3 intRow = rs.RecordCount intRow = intRow-1 for y=0 to intRow 'This IF section is testing the first letter of the acronym in the current and next record 'to determine if the letter changes so it can create breaks in the table denoting such changes 'therefore creating a table that is easier to scan and search. if NOT y = intRow then length = len(Array(1,y)) length = length - (len(Array(1,y))-1) temp = Array(1,y) temp = left(temp,length) z = y+1 length = 0 length = len(Array(1,z)) length = length - (len(Array(1,z))-1) temp2 = Array(1,z) temp2 = left(temp2,length) elseif y-intRow = 0 then 'If there is only one record returned we want to print the heading row that includes the letter 'of the alphabet this record begins with. This will also prevent the application from thinking that 'we are at the end of the record set and therefore not print out the special character , which 'is used in the else statement below. length = len(Array(1,y)) length = length - (len(Array(1,y))-1) temp = Array(1,y) temp = left(temp,length) else 'If the end of the database is reached, we need to stop the application from creating a final 'break in the table, using "" as the highest value character in ASCII. I don't how to create this 'character, I don't even know what it is, so I just copied it from another website. :) temp = "" end if 'Writes out every record in the table one record at a time. %>
<% if Session("LOGGEDIN") then %> <%=array(0,y)%> <% else %> <%=array(0,y)%> <% end if %>
<% response.write reBold.Replace (Array(1,y),"$1") %>
<% response.write reBold.Replace (Array(2,y),"$1") %>
<% 'If the IF statement above finds a change in the first letter of the acronym, we create 'a new alphabetic section with a corrosponding bookmark. if temp < temp2 then %><%=temp2 %> - Top <% switch = false end if response.write "" next end if rs.Close rs = null conn.Close conn = null %>