ASP code for script for predicting salmonella growth on tomatoes
- Written by Michael Mullan
Note this article is still in draft form and is available On Line to facilitate editing. It is scheduled to be completed by June 2015.
PHP has become particularly popular and is fairly easy to learn. Classic ASP is very easy to learn but is increasingly being replaced by ASP.NET. Virtually anyone who can put a spreadsheet together is capable of learning a basic language such as ASP.
The purpose of this article is to show how the calculator for predicting salmonella growth on tomatoes was written in ASP. I would like to encourage lecturers and students to learn how to programme. While ASP is being replaced by ASP.NET the basic premises using in ASP coding can be applied to other languages and even if you decide to learn PHP which is a particularly versatile web language you will be able to apply the concepts learned
Constructing the data entry form
The HTML and ASP code used to construct the data entry form is shown below. For simplicity web page header information, value information in ASP and some form security information has not been shown.
The input form was constructed by writing the code for a table in HTML and adding in HTML text boxes to allow initial number (no), temperature (t) and incubation time (hr) to be entered.
<form id="form1" name="form1" method="post" action="sam1.asp">
<table width="75%" border="1" cellspacing="0" cellpadding="1">
<th colspan="2" scope="col">Predict the growth of salmonella in cut tomatoes at 10°C to 35°C</th>
<td width="41%">Initial number of salmonella / gram</td>
<td width="59%"><input name="no" type="text" id="no" value="<%=no%>" /></td>
<td><input name="t" type="text" id="t" value="<%=t%>" /></td>
<td height="20">Incubation time, hours</td>
<td><input name="hr" type="text" id="hr" value="<%=hr%>" /></td>
<td height="20" colspan="2"><div align="center">
<input type="submit" name="Predict number of samonella" id="Predict number of samonella" value="Predict number of salmonella" />
Writing the data processing script
A simplified version of the processing script is given below. The notes which are preceded by a ' explain how the script works.
<% Option Explicit
'Use of option explicit will ensure that error messages are displayed if there are coding problems. These are helpful in finding solutions. %>
'no, t and hr are values that have been entered on the form
'r,g,gen, pop are the products of calculations that will be undertaken
'We will now obtain the information from the entry form to perform the calculation
'Taking information from the form we will calculate r,g, gen and pop. This could easily be done in one calculation. The calculation has been broken down into its component parts so that it can be followed more easily.
'For an explanation of the calculation please see http://www.dairyscience.info/index.php/food-model/258-predict.html
g=1/(r*r) 'note r is the square root of the growth rate, we need to obtain the growth rate by multiplying r by r
pop = no*2^gen
'We next need to provide the results of the calculation for pop which is the total number of salmonella after growth at the temperature chosen for the time inputted.
If t >9.99 AND t <35.01 THEN ' basic validation to ensure that the results are within the temperature parameters modelled
'The 'If Statement' is used to make a decision to execute code if some condition is True.
response.write ("The predicted number of samonella after" & " " & (hr)& " " & "hours has been calculated as" & " " & round(pop,0) & " " & "CFU/g.")
'END IF is used to indicate the end of code execution
IF t < 10 THEN
Response.Write (" Caution. This model as not been validated at temperatures <10°C.")
IF t > 35 THEN
Response.Write (" Caution. This model as not been validated at temperatures >35°C")
About the data processing script
To be added.
I learned ASP, how to use Access Databases and HTML from a former colleague Dr Raymond Martin. Raymond generously helped me correct concatenation and many other errors and though his help I gradually learned how to write quite sophisticated data-base driven ASP applications. I gratefully acknowledge Raymond's help over many years.
How to cite this article
Mullan, W.M.A. (2015). [On-line]. Available from: https://www.dairyscience.info/index.php/technology/260-asp.html . Accessed: 22 November, 2017.