Dairy Science and Food Technology

Scientific, information & consultancy services for the food industry

Copyright Protected

Content copyright protected

Science Services

DSFT has been providing science based consultancy services globally since 2002.
  
Click to learn more.

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.

There are several programming languages used to construct models that will run on web servers. These include Perl, PHP, Python, Classic ASP, JavaScript and ASP.Net. These languages can be used with appropriate databases to develop powerful web-based applications.

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.

 <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>

<form id="form1" name="form1" method="post" action="sam1.asp">

<table width="75%" border="1" cellspacing="0" cellpadding="1">
<tr>
<th colspan="2" scope="col">Predict the growth of salmonella in cut tomatoes at 10&deg;C to 35&deg;C</th>
</tr>
<tr>
<td width="41%">Initial number of salmonella / gram</td>
<td width="59%"><input name="no" type="text" id="no" value="<%=no%>" /></td>
</tr>
<tr>
<td>Temperature, &deg;C</td>
<td><input name="t" type="text" id="t" value="<%=t%>" /></td>
</tr>
<tr>
<td height="20">Incubation time, hours</td>
<td><input name="hr" type="text" id="hr" value="<%=hr%>" /></td>
</tr>
<tr>
<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" />
</div></td>
</tr>
</table>
<p>&nbsp;</p>
</form>


 

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.

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>


<% Option Explicit
'Use of option explicit will ensure that error messages are displayed if there are coding problems. These are helpful in finding solutions. %>

<%


'List variables

Dim no
Dim t
Dim hr

'no, t and hr are values that have been entered on the form
Dim r
Dim g
Dim gen
Dim pop

'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

no=CSng(Request.form("no"))
t=CSng(Request.form("t"))
hr=CSng(Request.form("hr"))


'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
 
r=0.026*(t)-0.1065
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
gen=hr/g
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" & "&nbsp;" & (hr)& "&nbsp;" & "hours has been calculated as" & "&nbsp;" & round(pop,0) & "&nbsp;" & "CFU/g.")
 END IF

'END IF is used to indicate the end of code execution


IF t < 10 THEN
Response.Write ("&nbsp; Caution. This model as not been validated at temperatures <10&deg;C.")
END IF

IF t > 35 THEN
Response.Write ("&nbsp; Caution. This model as not been validated at temperatures >35&deg;C")
END IF
%>

About the data processing script

These scripts will work on a Windows web server or a Windows PC running Microsoft's free IIS or PWS components. They are compressed and must be un-zipped before use. They have been provided free and are not warranted in any way. They are intended for educational use only. They can easily be adapted to work using PHP or JavaScript.

Qualifications/Disclaimer

To be added.

Acknowledgements

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: 3 December, 2016.  

We use cookies to improve our website and your experience when using it. To find out more about the cookies we use, see our Privacy and Cookie Policy.

'Learn more about managing cookies'