<%@ Language=VBScript %> <% Option Explicit Dim pagetitle, headerbgcolor, querystring, buttonname, oBody, pageBody pageTitle = "Watershed Database" headerbgcolor = "#84BD84" ' this is used in bodytop querystring = Request.QueryString() %> <% Set oBody = New FastString If firstHit = "true" Then pageTitle = "Welcome to the
Watershed Database" oBody.Append(" " & vbCrLf) oBody.Append(" " & vbCrLf) oBody.Append(" " & vbCrLf) oBody.Append(" " & vbCrLf) oBody.Append(" " & vbCrLf) oBody.Append(" " & vbCrLf) oBody.Append(" " & vbCrLf) oBody.Append(" " & vbCrLf) oBody.Append(" " & vbCrLf) oBody.Append(" " & vbCrLf) oBody.Append(" " & vbCrLf) oBody.Append("
" & vbCrLf) oBody.Append(" " & vbCrLf) oBody.Append(" " & vbCrLf) oBody.Append(" " & vbCrLf) oBody.Append(" " & vbCrLf) oBody.Append(" " & vbCrLf) oBody.Append("
" & vbCrLf) oBody.Append("

The Watershed Database was" & vbCrLf) oBody.Append(" created to make over 25 years of data from experimental" & vbCrLf) oBody.Append(" watersheds in Arizona available to all members of the" & vbCrLf) oBody.Append(" public as a teaching, learning, research, and decision making tool.

" & vbCrLf) oBody.Append("

Data from four watersheds, Beaver Creek, Castle Creek, Sierra Ancha, and Whitespar, are available" & vbCrLf) oBody.Append(" now, and we are working on adding data from other watersheds.

" & vbCrLf) oBody.Append("
" & vbCrLf) oBody.Append("

About the" & vbCrLf) oBody.Append(" Beaver Creek study
" & vbCrLf) oBody.Append(" The Beaver Creek Experimental Watershed was established in 1956 to" & vbCrLf) oBody.Append(" study the influence of various vegetative manipulations of pinyon-juniper" & vbCrLf) oBody.Append(" and ponderosa pine on water yield and to evaluate changes in livestock" & vbCrLf) oBody.Append(" forage, timber production, wildlife habitats, recreational values," & vbCrLf) oBody.Append(" and soil movement. [more...]

" & vbCrLf) oBody.Append("

How to use the database
" & vbCrLf) oBody.Append(" Using the database is as easy as making choices in the Data Access" & vbCrLf) oBody.Append(" Formon the left of this page, then clicking the create" & vbCrLf) oBody.Append(" recordsbutton. A more detailed" & vbCrLf) oBody.Append(" explanation of how to use the database is also available.

" & vbCrLf) oBody.Append("

" & vbCrLf) oBody.Append(" Users of this data should understand issues related to sampling error," & vbCrLf) oBody.Append(" measurement error, and others. An excellent introduction to some of these" & vbCrLf) oBody.Append(" issues is available on" & vbCrLf) oBody.Append(" this site describing forest measurement and modelling error (courtesy" & vbCrLf) oBody.Append(" of Cris Brack, Department of Forestry, Australian National University).

" & vbCrLf) oBody.Append("

Developers of this site also request that any publications using data" & vbCrLf) oBody.Append(" from the Beaver Creek Experimental Watershed must include the following" & vbCrLf) oBody.Append(" paragraph:

" & vbCrLf) oBody.Append("
" & vbCrLf) oBody.Append("

Some data used in this publication was obtained by" & vbCrLf) oBody.Append(" scientists of the Beaver Creek Watershed Project and other research watersheds" & vbCrLf) oBody.Append(" and was made available through the Managing Arid and Semi-arid Watersheds website" & vbCrLf) oBody.Append(" (http://ag.arizona.edu/OALS/watershed/). This publication has not been reviewed by" & vbCrLf) oBody.Append(" those scientists. The Beaver Creek Experimental Watershed is operated and maintained" & vbCrLf) oBody.Append(" by the Rocky Mountain Research Station, U.S. Department of Agriculture, Fort Collins," & vbCrLf) oBody.Append(" Colorado.

" & vbCrLf) oBody.Append("
" & vbCrLf) oBody.Append("
" & vbCrLf) Else '******************************************************************* '* OPEN CONNECTION OBJECT '******************************************************************* pageTitle = "Database Results" Dim objConn, dbPath dbPath = "e:\websites\alic_watershed\watershed_db\watersheddata.mdb" Set objConn = Server.CreateObject("ADODB.Connection") objConn.Open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" & dbPath '******************************************************************* '* CREATE SQL STRING '******************************************************************* Dim strMainSQL, objRS, where, strControlSQL, recSet, dsuse where = 0 '-------------------------------------------------------------------- ' get the control watershed's number, if user ' selects control for comparison graph '-------------------------------------------------------------------- If compareTo = "control" Then strControlSQL = "SELECT control FROM CONTROLWATERSHED WHERE watershed = '" & location & "'" 'oBody.Append("

strControlSQL = " + strControlSQL + "

") Set recSet = Server.CreateObject("ADODB.RecordSet") recSet.Open strcontrolSQL, objConn compareTo = recSet.fields("control") recSet.close set recSet = nothing End If '-------------------------------------------------------------------- ' beaver creek tables don't have the watershed letters in front, ' but all the rest will. Add those letters here. '-------------------------------------------------------------------- If shed = "bc" Then dsuse = ds Else dsuse = shed & ds End If ' ------------------------------------------------------------------- ' if request is for documentation ' ------------------------------------------------------------------- If ds = "info" Then If subset = "Watershed" or subset = "Gage" Then strMainSQL = "SELECT * FROM " & ds & subset & " WHERE " & instrument & " = '" & location & "'" Else strMainSQL = "SELECT * FROM " & subset End If ' ------------------------------------------------------------------- ' if requesting data instead of documentation, set up basic sql ' ------------------------------------------------------------------- Else strMainSQL = "SELECT * FROM " & dsuse & subset If location <> "ALL" Then strMainSQL = strMainSQL & " WHERE (" & instrument & " = '" & location & "'" where = 1 if (compareTo <> "" and compareTo <> location) Then strMainSQL = strMainSQL & " OR " & instrument & " = '" & compareTo & "'" strMainSQL = strMainSQL & ")" End If '-------------------------------------------------------------------- ' add date parameters to sql string '-------------------------------------------------------------------- If where = 1 Then strMainSQL = strMainSQL & " AND " Else strMainSQL = strMainSQL & " WHERE " End If If subset = "Annual" Then strMainSQL = strMainSQL & "RYEAR >= " & startyear strMainSQL = strMainSQL & " AND RYEAR <= " & endyear End If If subset = "Monthly" or ds = "range" or ds = "timber" Then strMainSQL = strMainSQL & "((RYEAR = " & startyear & " AND RMONTH >= " & startmonth & ")" strMainSQL = strMainSQL & " OR (RYEAR > " & startyear & " AND RYEAR < " & endyear & ")" strMainSQL = strMainSQL & " OR (RYEAR = " & endyear & " AND RMONTH <= " & endmonth & "))" End If If subset = "Daily" or subset = "Cfs" or ds="sediment" Then strMainSQL = strMainSQL & "((Year(RDATE) = " & startyear & " AND Month(RDATE) >= " & startmonth & ")" strMainSQL = strMainSQL & " OR (Year(RDATE) > " & startyear & " AND Year(RDATE) < " & endyear & ")" strMainSQL = strMainSQL & " OR (Year(RDATE) = " & endyear & " AND Month(RDATE) <= " & endmonth & "))" End If '------------------------------------------------------------------- ' add sql to sort appropiately, depending on ds and/or subset '------------------------------------------------------------------- Dim order order = "WATERSHED, RYEAR" If not dataByWatershed Then If subset = "Annual" or subset = "Monthly" Then order = "GAGE, RYEAR" End If If subset = "Monthly" then order = order & ", RMONTH" End If If subset = "Daily" Then order = "GAGE, RDATE" End If Else If subset = "Monthly" then order = order & ", RMONTH" End If if subset = "Daily" or subset = "Cfs" then order = "WATERSHED, RDATE" if subset = "Cfs" then order = order & ", RTIME" End If End If if ds = "range" then order = order & ", RMONTH, RDAY, CLUSTER, PLOT" end if if ds = "timber" then order = order & ", RMONTH" end if End If If ds = "sediment" Then order = "WATERSHED, Year(RDATE), Month(RDATE), Day(RDATE), RTIME" If ds = "radiation" Then order = "Year(RDATE), Month(RDATE), Day(RDATE)" strMainSQL = strMainSQL & " ORDER BY " & order End If '********debugging print of variable 'oBody.Append("

SQL = " + strMainSQL + "

" & vbCrLf) '******************************************************************** '* RUN QUERY SQL STRING TO MAKE RECORDSET '******************************************************************** If not subset = "none" and not subset = "first" Then Dim rsSF, rsArea Set rsSF = Server.CreateObject("ADODB.Recordset") Set rsArea = Server.CreateObject("ADODB.Recordset") '********debugging print of variable 'oBody.Append("

SQL = " + strMainSQL + "

" & vbCrLf) rsSF.Open strMainSQL, objConn, 1, 1, 1 ' rsSF.Open strMainSQL, objConn, 3, 3 If objConn.Errors.Count > 0 Then oBody.Append("

ERROR! " & objConn.Errors.Count & " Recordset open error(s)!

" & vbCrLf) For intCounter = 0 to objConn.Errors.Count - 1 oBody.Append("

Count = " & intCounter & _ ", code = " & objConn.Errors(intCounter).Number & _ ", description = " & objConn.Errors(intCounter).Description & ".

" & vbCrLf) Next 'objConn.Errors.Clear End If Else 'subset = "none" oBody.Append("

The server could not process your request.

Please choose a valid subset

(valid subsets are represented by bulleted entries in the subset pulldown menu)

") End If ' subset <> 'none' Dim Counter Counter = 0 Dim i i = 0 If (rsSF.RecordCount = 0) Then format = "none" End If Dim formathere If (Left(format, 4) = "html") Then formathere = "html" Else formathere = format End If '********debugging print of variable 'oBody.Append("SQL: " & strMainSQL & vbCrLf) Select Case formathere Case "none" Call doNoRecords Case "graph" Response.Redirect "http://alic.arid.arizona.edu/IALC/graphtools/creatplot.jsp?shed=" & shed & "&ds=" & ds & "&subset=" & subset & "&location=" & location & "&startmonth=" & startmonth & "&startyear=" & startyear & "&endmonth=" & endmonth & "&endyear=" & endyear & "&plotType=Line&Submit=Create+Records&shedIndex=0&dsIndex=0&subsetIndex=0&locationIndex=0" 'oBody.Append("http://nazca.arid.arizona.edu/IALC/graphtools_new/creatplot2.jsp?shed=" & shed & "&ds=" & ds & "&subset=" & subset & "&location=" & location & "&startmonth=" & startmonth & "&startyear=" & startyear & "&endmonth=" & endmonth & "&endyear=" & endyear & "&plotType=Line&Submit=Create+Records&shedIndex=0&dsIndex=0&subsetIndex=0&locationIndex=0") Case "Description" Call doDescription Case "html" Call doHtml Case "ascii" Call doAscii Case Else Call doQuit End Select End If' end of body, all the way from 'else' on line ~51 pageBody = oBody.concat '******************************************************************** ' handle if no records are returned '******************************************************************** Sub doNoRecords oBody.Append("

Sorry, there are no data for your request.

") oBody.Append("

Please try another query.

") oBody.Append(" " & vbCrLf) oBody.Append(" " & vbCrLf) End Sub 'doNoRecords '******************************************************************** ' handle GRAPH request ' this sub no longer used because of the new graphing tool '******************************************************************** Sub doGraph Dim treatmentRS, treatmentYear, treatment, strGraphSQL oBody.Append("

Graph of " & subset & " " & dsToWrite & "
from " & startmonth & "/" & startyear & " to " & endmonth & "/" & endyear & " for " & dataName & " " & location & "

" & vbCrLf) If compareTo <> "" Then oBody.Append("

Compared to: " & dataname & " " & compareTo & "

" & vbCrLf) If databywatershed Then Set treatmentRS = Server.CreateObject("ADODB.REcordSet") strGraphSQL = "SELECT TREATMENT, TREATMENTYEAR FROM INFOWATERSHED WHERE WATERSHED='" & location & "'" treatmentRS.Open strGraphSQL, objConn, 1, 1, 1 treatment = treatmentRS.fields("treatment") treatmentyear = treatmentRS("treatmentyear") treatmentRS.close set treatmentRS = Nothing oBody.Append("

Treatment: " & treatment & " " & treatmentyear & "

" & vbCrLf) End If '------------------------------------------------------------------------------ ' set some variables, depending on ds and subset '------------------------------------------------------------------------------ Dim xData, yData, x2Data, y2Data Dim xName, yName Dim xTable, yTable Dim xCol, yCol Select Case ds '-----------------------' 'PRECIPITATION WATERSHED' '-----------------------' Case "precipitationWatershed" yName = "Total_Precipitation_(inches)" Select Case subset Case "Annual" xName = "Year" xCol = "RYEAR" yCol = "TOTAL" Case "Monthly" xName = "Month/Year" yCol = "AMT" Case "Daily" xName = "Date" xCol = "RDATE" yCol = "AMT" Case Else xName = "Error - tell webmaster" xCol = "Error" End Select '------------------' 'PRECIPITATION GAGE' '------------------' Case "precipitationGage" yName = "Total_Precipitation_(inches)" Select Case subset Case "Annual" xName = "Year" xCol = "RYEAR" yCol = "TOTALPRECIP" Case "Monthly" xName = "Month/Year" yCol = "AMOUNT" Case "Daily" xName = "Date" xCol = "RDATE" yCol = "AMT" Case Else xName = "Error - tell webmaster" xCol = "Error" End Select '--------' 'HUMIDITY' '--------' Case "humidity" yName = "Average_Humidity" Select Case subset Case "Annual" xName = "Year" xCol = "RYEAR" yCol = "AVERAGE" Case "Monthly" xName = "Month/Year" yCol = "AVERAGE" Case "Daily" xName = "Date" xCol = "RDATE" yCol = "AVG" Case Else xName = "Error - tell webmaster" xCol = "Error" End Select '----------' 'STREAMFLOW' '----------' Case "strmflow" Select Case subset Case "Annual" xName = "Year" yName = "Yearly_Volume_(acre-ft)" xCol = "RYEAR" yCol = "YEARLY" Case "Monthly" xName = "Month/Year" yName = "Monthly_Volume_(acre-ft)" yCol = "VOL" Case "Daily" xName = "Date" yName = "Daily_Volume_(ft³)" xCol = "RDATE" yCol = "CUBFT" Case Else xName = "Error - tell webmaster" xCol = "Error" End Select '-----------' 'TEMPERATURE' '-----------' Case "temperature" yName = "Average_Temperature_(°F)" yCol = "AVG" Select Case subset Case "Annual" xName = "Year" xCol = "RYEAR" Case "Monthly" xName = "Month/Year" Case "Daily" xName = "Date" xCol = "RDATE" Case Else xName = "Error - tell webmaster" xCol = "Error" End Select Case Else End Select 'ds '*********************************************************************' '* END DEFINING VARIOUS DS AND subset CHOOSING OF XNAME, ETC. '* NOW PUT TOGETHER DATA STRINGS FOR GRAPH'S IMAGE CODE '*********************************************************************' Dim count If fixgraph = "true" Then count = limit Else count = rsSF.RecordCount End If If subset = "Monthly" Then For i = 1 to count If rsSF.Fields( dataName ).value = compareTo Then x2Data = x2Data & rsSF.Fields( "RMONTH" ).value & "/" & rsSF.Fields( "RYEAR" ).value y2Data = y2Data & rsSF.Fields( yCol ).value rsSF.moveNext If i < count Then x2Data = x2Data & "," y2Data = y2Data & "," End If Else xData = xData & rsSF.Fields( "RMONTH" ).value & "/" & rsSF.Fields( "RYEAR" ).value yData = yData & rsSF.Fields( yCol ).value rsSF.moveNext End If If i < count Then xData = xData & "," yData = yData & "," End If Next Else For i = 1 to count If rsSF.Fields(dataName) = location Then xData = xData & rsSF.Fields( xCol ).value yData = yData & rsSF.Fields( yCol ).value If i < count Then xData = xData & "," yData = yData & "," End If ElseIf rsSF.Fields(dataName) = compareTo and compareTo <> location Then x2Data = x2Data & rsSF.Fields( xCol ).value y2Data = y2Data & rsSF.Fields( yCol ).value If i < count Then x2Data = x2Data & "," y2Data = y2Data & "," End If End If rsSF.moveNext Next End If Dim numRecords numRecords = count rsSF.Close set rsSF = Nothing objConn.Close Set objConn = Nothing 'graph data now complete, put image on page 'this sets the extra data for a comparison graph Dim strXaxis, strCompData strCompData = "" If compareTo <> "" and compareTo <> location Then strCompData = "&dataset1xValues=" & x2Data & "&dataset1yValues=" & y2Data End If If count > limit Then oBody.Append(" " & vbCrLf) oBody.Append(" " & vbCrLf) oBody.Append(" " & vbCrLf) oBody.Append(" " & vbCrLf) oBody.Append("
" & vbCrLf) oBody.Append("

There were too many data points to" & vbCrLf) oBody.Append(" create a readable line graph.

" & vbCrLf) oBody.Append("

This line graph can graph up to " & limit & " records at one time." & vbCrLf) oBody.Append(" Your last query returned " & numRecords & " records.

" & vbCrLf) oBody.Append("

We can fix the" & vbCrLf) oBody.Append(" graph for you by using the first " & limit & " records, or you may do a new search with parameters that limit the records to this number.

" & vbCrLf) oBody.Append("

" & querystring & "

" & vbCrLf) oBody.Append("
" & vbCrLf) else If chartType = "columnApp" then strXaxis = "&xAxisLabels=" End If If chartType = "lineApp" Then If subset = "Daily" or subset = "Monthly" then If compareTo <> "" Then strXaxis = "&dataset0xValues=" Else strXaxis = "&xAxisLabels=" chartType = "labelLineApp" End If Else strXaxis = "&dataset0xValues=" End If End if oBody.Append(" " ) End if If Not Request.QueryString("toprint") = "true" Then ' buttons used to change graph format oBody.Append("
" & vbCrLf) oBody.Append("
Change chart type:" & vbCrLf) oBody.Append(" Line" & vbCrLf) oBody.Append(" Bar" & vbCrLf) oBody.Append(" " & vbCrLf) oBody.Append(" " & vbCrLf) oBody.Append(" " & vbCrLf) oBody.Append(" " & vbCrLf) oBody.Append(" " & vbCrLf) oBody.Append(" " & vbCrLf) oBody.Append(" " & vbCrLf) oBody.Append(" " & vbCrLf) oBody.Append(" " & vbCrLf) oBody.Append(" " & vbCrLf) If fixgraph = "true" Then oBody.Append(" " & vbCrLf) End If oBody.Append("
" & vbCrLf) oBody.Append("
" & vbCrLf) End If 'toprint = "true" If subset = "Annual" and not Request.QueryString("toprint") = "true" Then 'parenthetical part used to be: (chartType = "lineApp" or chartType = "labelLineApp") ' only show compare form if subset = annual 'form that's used to choose the gage/watershed to graphicly compare with 'location' oBody.Append("
" & vbCrLf) oBody.Append("
Compare graph to" & vbCrLf) oBody.Append(" ">
<% End if 'if subset = annual - this hides the compare graph form from above End Sub 'doGraph '******************************************************************** ' HANDLE DESCRIPTION REQUEST '******************************************************************** Sub doDescription If subset = "Gage" or subset = "Watershed" Then oBody.Append("

Description of " & dataName & " " & location & "

" & vbCrLf) else oBody.Append("

Data Set Description for:
" & subsetToWrite) 'if location <> "ALL" then ' oBody.Append("for " & dataName & " " & location) 'end if oBody.Append("

" & vbCrLf) end if rsSF.MoveFirst oBody.Append("" & vbCrLf ) Do While Not rsSF.EOF If not location = "ALL" Then For Counter = 1 To rsSF.fields.count - 1 oBody.Append(" " & vbCrLf) oBody.Append(" " & vbCrLf) oBody.Append(" " & vbCrLf ) oBody.Append(" " & vbCrLf) Next Else oBody.Append(" " & vbCrLf) oBody.Append(" " & vbCrLf ) oBody.Append(" " & vbCrLf) oBody.Append(" " & vbCrLf) oBody.Append(" " & vbCrLf ) oBody.Append(" " & vbCrLf) oBody.Append(" " & vbCrLf & " " & vbCrLf & " ") For Counter = 3 To rsSF.fields.count - 1 oBody.Append(" " & vbCrLf) oBody.Append(" " & vbCrLf ) oBody.Append(" " & vbCrLf ) oBody.Append(" " & vbCrLf) Next End If rsSF.MoveNext Loop oBody.Append("
" & rsSF.Fields( Counter ).Name & ": " & rsSF.Fields( Counter ).Value & "
" & vbCrLf & "

Data set name:

" & vbCrLf) oBody.Append("

" & rsSF.Fields( "NAME" ).Value & "

" & vbCrLf & "

Data set overview:

" & vbCrLf) oBody.Append("

" & rsSF.Fields( "OVERVIEW" ).Value & "

" & vbCrLf & "

Description of data table columns:

" & vbCrLf & "
" & rsSF.Fields( Counter ).Name & ": " & rsSF.Fields( Counter ).Value & "
" & vbCrLf & "" & vbCrLf & "" & vbCrLf) rsSF.Close set rsSF = Nothing objConn.Close Set objConn = Nothing End Sub 'doDescription '******************************************************************** '* Handle case HTML format '******************************************************************** Sub doHtml If location = "ALL" Then oBody.Append("

" & shedToWrite & "
" & subset & " " & dstowrite & "

" & vbCrLf) oBody.Append("

" & MonthName(startmonth) & " " & startyear & " to " & MonthName(endmonth) & " " & endyear & ", ") oBody.Append(location & " " & dataName & "s

" & vbCrLf) Else oBody.Append("

" & shedToWrite & "
" & subset & " " & dstowrite & "

" & vbCrLf) oBody.Append("

" & MonthName(startmonth) & " " & startyear & " to " & MonthName(endmonth) & " " & endyear & ", ") oBody.Append(dataName & " " & location & "

" & vbCrLf) End if pageSize = CInt(Mid(format, 5)) If pageSize = Empty Then pageSize = 10 End If If Not rsSF.EOF Then Dim totalPage, totalRec totalRec = rsSF.RecordCount totalPage = Int(totalRec/pageSize) If (totalRec Mod pageSize) <> 0 Then totalPage = totalPage + 1 End If End If 'set a value if there are no records Dim recs If totalRec > 0 Then recs = totalRec oBody.Append(" " & vbCrLf) oBody.Append(" " & vbCrLf) oBody.Append(" " & vbCrLf) Dim field '****** '*write out the table header row, with field names for headings '****** For Counter = 1 To rsSF.Fields.Count - 1 field = rsSF.Fields(Counter).Name oBody.Append(" " & vbCrLf) Next oBody.Append(" ") '****** '* using the pageSize requested... '****** i = 0 rsSF.MoveFirst If currentPage > 1 Then rsSF.Move (pageSize * (currentPage - 1) ) End If Do While i < pageSize and Not rsSF.EOF i = i + 1 'Print data oBody.Append(" " & vbCrLf) '****** '* ...write out the data rows of the table. '****** Dim divideby, dodivide, decimals, thiswatershed, area For Counter = 1 To rsSF.Fields.Count - 1 oBody.Append(" " & vbCrLf) Next oBody.Append(" " & vbCrLf) rsSF.MoveNext Loop Set rsArea = Nothing rsSF.Close set rsSF = Nothing Else ' if the user clicks on basic fields to be displayed oBody.Append("
  • Click here to display all fields
  • ") & vbCrLf oBody.Append(" " & vbCrLf) oBody.Append(" " & vbCrLf) oBody.Append("
    " & vbCrLf & " ") If field = "CUBFT" Then field = "IN" oBody.Append(field & "
    ") If IsNull( rsSF.Fields(Counter).Value ) Then oBody.Append(" " & vbCrLf) Else Select Case rsSF.Fields(Counter).Name Case "WATERSHED" If (thiswatershed <> rsSF.Fields(Counter).Value) Then 'don't do this unless necessary thiswatershed = rsSF.Fields(Counter).Value strMainSQL = "select area from area where ws = '" & thiswatershed & "'" ' find the area (in acres) of the watershed rsArea.Open strMainSQL, objConn, 1, 1, 1 If Not (rsArea.EOF) Then area = rsArea("area") End If rsArea.Close End If dodivide = FALSE Case "DBH" ' these cases are all to handle the situation where the data is in different units or needs a factor to seen correctly divideby = 10 dodivide = TRUE decimals = 1 Case "GROSS" divideby = 10 dodivide = TRUE decimals = 1 Case "TARE" divideby = 10 dodivide = TRUE decimals = 1 Case "CRUCFILT" divideby = 10000 dodivide = TRUE decimals = 4 Case "CRUCSED" divideby = 10000 dodivide = TRUE decimals = 4 Case "PPM" divideby = 1000 dodivide = TRUE decimals = 3 Case "CUBFT" divideby = 3630 * area dodivide = TRUE decimals = 5 Case Else dodivide = FALSE End Select If dodivide Then ' use those values to format the output correctly oBody.Append(formatnumber(rsSF.Fields(Counter).Value/divideby, decimals)) Else oBody.Append(rsSF.Fields(Counter).Value) End If End If oBody.Append("
    " & vbCrLf) oBody.Append(" " & vbCrLf) '****** '* using the data in the dataFields table print out the header row for table... '****** Dim fieldsRS, counter, fieldsArray, k, strHtmlSQL strHtmlSQL = "select * from dataFields WHERE TABLE = '" & shed & ds & subset & "'" 'oBody.Append("

    strHtmlSQL: " & strHtmlSql & "

    ") Set fieldsRS = Server.CreateObject("ADODB.Recordset") fieldsRS.Open strHtmlSQL, objConn, 1, 1, 1 fieldsArray = split(fieldsRS.Fields("FIELDS"),",") For counter = 0 To UBound(fieldsArray) field = rsSF.Fields(CInt(fieldsArray(counter))).Name oBody.Append(" " & vbCrLf) Next oBody.Append(" " & vbCrLf) '****** '* ...then the data rows. '****** k = 0 rsSF.MoveFirst If currentPage > 1 Then rsSF.Move (pageSize * (currentPage - 1) ) End If Do While k < pageSize and Not rsSF.EOF k = k + 1 'Print data oBody.Append(" " & vbCrLf ) For counter = 0 To UBound(fieldsArray) field = rsSF.Fields(CInt(fieldsArray(counter))) oBody.Append(" " & vbCrLf ) Next oBody.Append(" " & vbCrLf ) rsSF.MoveNext Loop Set rsArea = Nothing rsSF.Close set rsSF = Nothing fieldsRS.Close set fieldsRS = Nothing End If oBody.Append("
    ") If field = "CUBFT" Then field = "IN" oBody.Append(field & "
    ") If IsNull(field) Then oBody.Append(" ") Else Select Case rsSF.Fields(CInt(fieldsArray(counter))).Name Case "WATERSHED" If (thiswatershed <> rsSF.Fields(CInt(fieldsArray(counter))).Value) Then 'don't do this unless necessary thiswatershed = rsSF.Fields(CInt(fieldsArray(counter))).Value strMainSQL = "select area from area where ws = '" & thiswatershed & "'" rsArea.Open strMainSQL, objConn, 1, 1, 1 If Not (rsArea.EOF) Then area = rsArea("area") End If rsArea.Close End If dodivide = FALSE Case "DBH" divideby = 10 dodivide = TRUE decimals = 1 Case "GROSS" divideby = 10 dodivide = TRUE decimals = 1 Case "TARE" divideby = 10 dodivide = TRUE decimals = 1 Case "CRUCFILT" divideby = 10000 dodivide = TRUE decimals = 4 Case "CRUSED" divideby = 10000 dodivide = TRUE decimals = 4 Case "PPM" divideby = 1000 dodivide = TRUE decimals = 3 Case "CUBFT" divideby = 3630 * area dodivide = TRUE decimals = 5 Case Else dodivide = FALSE divideby = 1 End Select If dodivide Then oBody.Append(formatnumber(field/divideby, decimals)) Else oBody.Append(field) End If End If oBody.Append("
    " & vbCrLf) oBody.Append("

    Results: There were " & recs & " total records returned.

    " & vbCrLf) oBody.Append("

    Page " & currentPage & " of " & totalPage & " pages.

    " & vbCrLf) 'do the links to other pages Dim j, startPage, maxPages, endPage maxPages = 10 startPage = currentPage - maxPages endPage = currentPage + maxPages If totalPage <= maxPages Then maxPages = totalPage End If If currentPage < maxPages Or startPage < 1 Then startPage = 1 End If If currentPage + maxPages > totalPage Then endPage = totalPage End If ' oBody.Append("

    strParamsPassed: " & strParamsPassed & "
    ") ' oBody.Append("Request.QueryString: " & Request.QueryString & "

    ") ' oBody.Append("

    pageSize: " & pageSize & "

    ") oBody.Append("

    Pages:") If startPage > 1 Then oBody.Append(" First page ... " ) End If For j = startPage to currentPage - 1 oBody.Append(vbCrLf & " " & j & "" ) Next oBody.Append(vbCrLf & " " & currentPage & "") For j = currentPage + 1 To endPage oBody.Append(vbCrLf & " " & j & "" ) Next If totalPage - currentPage > maxPages Then oBody.Append(vbCrLf & " ... Last page (" & totalPage & ")" ) End If oBody.Append(vbCrLf & "

    " & vbCrLf) oBody.Append(" " & vbCrLf) oBody.Append(" " & vbCrLf) objConn.Close Set objConn = Nothing End Sub 'doHtml '******************************************************************** '* Handle ACSII output here '******************************************************************** Sub doAscii dim fs, a, divideby, dodivide, decimals Set fs = CreateObject("Scripting.FileSystemObject") dim path path = downloaddir & downloadpath & location & "_" & ds & subset & "_" & MonthName(startmonth, true) & startyear & "-" & monthName(endmonth, true) & endyear & ".csv" ' oBody.Append(path) Set a = fs.CreateTextFile( path, true ) oBody.Append("

    Watershed Database file download

    " & vbCrLf) oBody.Append("

    Your file has been prepare from the database.

    " & vbCrLf) oBody.Append(" " & vbCrLf) oBody.Append(" " & vbCrLf) oBody.Append(" " & vbCrLf) oBody.Append(" " & vbCrLf) oBody.Append(" " & vbCrLf) oBody.Append(" " & vbCrLf) oBody.Append(" " & vbCrLf) oBody.Append("
    " & vbCrLf) oBody.Append(" File Description:" & vbCrLf) oBody.Append("
    " & vbCrLf) oBody.Append("     Database: " & dstowrite & "
    " & vbCrLf) oBody.Append("     Subset: " & subset & "
    " & vbCrLf) oBody.Append("     " & dataName & ": " & location & "
    " & vbCrLf) oBody.Append("     Start Date: " & monthname(startmonth, true) & " " & startyear & "
    " & vbCrLf) oBody.Append("     End Date: " & monthname(endmonth, true) & " " & endyear & "
    " & vbCrLf) oBody.Append("
    " & vbCrLf) oBody.Append("

    Click here to download the file.

    " & vbCrLf) oBody.Append(" " & vbCrLf) oBody.Append(" " & vbCrLf) For Counter = 1 To rsSF.Fields.Count - 1 a.Write( """" ) a.Write( rsSF.Fields( Counter ).Name ) if counter = rssf.Fields.Count - 1 Then a.Write( """" ) else a.Write( """," ) end if Next i = 0 rsSF.MoveFirst Do While Not rsSF.EOF i = i + 1 a.write(vbNewLine) For Counter = 1 To rsSF.Fields.Count - 1 a.write( """" ) dim temp temp = rsSF.Fields( Counter ).Value if isNull(temp) Then a.Write( "" ) else Select Case rsSF.Fields(Counter).Name Case "DBH" divideby = 10 dodivide = TRUE decimals = 1 Case "GROSS" divideby = 10 dodivide = TRUE decimals = 1 Case "TARE" divideby = 10 dodivide = TRUE decimals = 1 Case "CRUCFILT" divideby = 10000 dodivide = TRUE decimals = 4 Case "CRUSED" divideby = 10000 dodivide = TRUE decimals = 4 Case "PPM" divideby = 1000 dodivide = TRUE decimals = 3 Case Else dodivide = FALSE End Select If dodivide Then a.Write(formatnumber(temp/divideby, decimals)) Else a.Write(temp) End If end if if counter = rssf.Fields.Count - 1 Then a.Write( """" ) else a.Write( """," ) end if Next rsSF.MoveNext Loop a.close rsSF.Close set rsSF = Nothing objConn.Close Set objConn = Nothing End Sub 'doAscii Sub doQuit oBody.Append("Sqizzlewiggy, something's wrong! You only get here if a format is not handled by the select case format around line 254.") End Sub %> Managing Semi-Arid Watersheds: <%=pageTitle%>
    Managing Arid and Semi-Arid Watersheds
    Button linking to home page Button linking to information about this site Button linking to information about the Arizona Watershed Program Button linking to the section on the Central Arizona Highlands Button linking to a searchable bibliography of literature from the Arizona Watershed Progam Button linking to external site with images from the Arizona Watershed Program
    Button linking to a set of documents on the basics of watersheds Button linking to a page of links and information for teachers, their students and others interested in learning about watersheds Button linking to a page of links to other sites with information on watersheds Button linking to a page with which to give us feedback about this site
    Watershed:
       
    Data Set:
       
    Subset:
       
    Location:
       
    Start date:
       Month Year
    End date:
       Month Year
    Output format:
       

    Tools:

    <%=PageTitle%>

    <%=PageBody%>

    Home | Research Data Home Page
    credits