home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 February / CHIP_2_98.iso / software / pelne / optionp / iis4_06.cab / samp58hf.asp < prev    next >
Text File  |  1997-10-03  |  3KB  |  44 lines

  1.  <% If Request("DontFrame")<>1 Then Response.Redirect "/iissamples/sdk/asp/docs/SampFram.asp?ovfile=/iishelp/iis/htm/sdk/samp58hf.asp&srcfile=Simple/Functions" %>
  2. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
  3. <HTML>
  4. <HEAD>
  5. <META HTTP-EQUIV="Content-Type" Content="text-html; charset=Windows-1252">
  6. <title>Functions and Procedures</title>
  7. <script language="JavaScript">
  8.  
  9.     szNavVersion = navigator.appVersion
  10.  
  11.     if (navigator.appName == "Microsoft Internet Explorer") {
  12.     if (szNavVersion.indexOf ("4.") >= 0) {
  13.         document.writeln('<link rel="stylesheet" type="text/css" href="/iishelp/common/spidie4.css">');
  14.     } else {
  15.         document.writeln('<link rel="stylesheet" type="text/css" href="/iishelp/common/spidie3.css">');
  16.     }
  17.     }
  18.     else if (navigator.appName == "Netscape") {
  19.     document.writeln('<link rel="stylesheet" type="text/css" href="/iishelp/common/spidie4.css">');
  20.     }
  21.     else {
  22.     document.writeln('<link rel="stylesheet" type="text/css" href="/iishelp/common/spidie3.css">');
  23.     }
  24.  
  25. </script>
  26. <META NAME="DESCRIPTION" CONTENT="Internet Information Server reference information"></HEAD>
  27. <BODY BGCOLOR=#FFFFFF TEXT=#000000>
  28. <font face="Verdana, Arial, Helvetica">
  29. <h3><a name="_functions_and_procedures"></a>Functions and Procedures</h3>
  30. <p>
  31. Functions and procedures provide you with a convenient way to avoid having to rewrite the same block of code every time you want to perform a particular task. Both VBScript and JScript allow you to call a function or procedure from any point in a script. This sample demonstrates how you can create and use these tools with ASP. </p>
  32. <p>
  33. If you don't have any functions in your ASP page, the ASP engine simply processes your entire file, start to finish, each time it is requested by a client browser. Functions and procedures, however, are executed only when called, not in-line with the rest of the code. </p>
  34. <p>
  35. You can denote functions and procedures in VBScript or JScript using the <b>Function</b> statement. In addition, VBScript makes a distinction between a function that returns a value and functions that do not; the latter type are denoted with the <b>Sub</b> statement, indicating that it is a subroutine. </p>
  36. <p>
  37. This sample defines one function, <b>PrintOutMsg</b>, that takes as parameters a message, and a number that specifies how many times the message is to be written to the client browser with the <b>Response.Write</b> method. The function, for the purposes of this sample, simply returns the number of times the message was printed back to the client browser. </p>
  38. <p>
  39. It is also very important to note the RUNAT attribute of the <SCRIPT> tag. If this attribute is not included, ASP will assume that it is client-side scripting, and will pass the code back to the browser for processing. ASP would then not recognize <b>PrintOutMsg</b>, and would return an error and abort. </p>
  40. <hr class="iis" size="1">
  41. <p align="center"><em><a href="/iishelp/common/colegal.htm">© 1997 by Microsoft Corporation. All rights reserved.</a></em></p>
  42. </BODY>
  43. </HTML>
  44.