ASP
  Home arrow ASP arrow Page 2 - The Real Basics of Functions in ASP
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Mobile Linux 
App Generation ROI 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
ASP

The Real Basics of Functions in ASP
By: John Puddifoot
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 260
    2004-12-21

    Table of Contents:
  • The Real Basics of Functions in ASP
  • Simplemaths
  • Customer Spec Part 2
  • A Common ASP Task
  • Calling the Function

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    The Real Basics of Functions in ASP - Simplemaths


    (Page 2 of 5 )

    Ok, pretty simple – so let’s complicate this one with by wrapping it up in a function called "simplemaths." Let’s look at the function protocol first:

    <%
    function simplemaths(var1, var2)

    end function
    %>

    We’ve created a function (which doesn’t actually do anything yet). It needs two input variables (var1 and var2). We would then use the following code to call the function if both of our variables equalled 3 and 2:

    <%
    call simplemaths(3, 2)
    %>

    Simple, right? All that we need now is to edit our function so that it actually does something! Just as the customer requested, the function will simply add our two values together and produce the result on screen.

    <%
    'Define our function
    function simplemaths(var1, var2)
      result=var1+var2
      response.write result & "<br />"
    end function

    'run the function
    call simplemaths(3, 2)
    %>

    Note that var1 and var2 are the variable names within the function and not outside it. You could choose to use variables outside of the function too. To add 10 and 20 together using variables:

    <%
    'Define our function
    function simplemaths(var1, var2)
      result=var1+var2
      response.write result & "<br />"
    end function

    input1=10
    input2=20

    call simplemaths(input1, input2)
    %>

    More ASP Articles
    More By John Puddifoot


       · The code works great to add new records to a database. However, if you need to...
       · Here is the most valuable function for asp. Place this into global.asas or a...
       · function db_dropdown(sTable, sId, sDropdownName, sBoundfield,...
       · What does the value of "sID" represent? Is it the value of the field from Table1 in...
       · ' Create a suitable connection object for a given connection string. Function...
       · ' Create a suitable connection object for a given connection string. Function...
       · This is very good but i don't why this doesn't work???
       · simple... but VERY cool.
       · I have problem to seek them, because I don't have this software...?
       · function db_dropdown(tablename, bound_field, display_field,order_field,...
     

    ASP ARTICLES

    - Using MySQL with ASP
    - ADO for the Beginner
    - ADO.NET 101: Data Rendering with a DataGrid ...
    - Introducing SoftArtisans OfficeWriter 3.0 En...
    - Getting Remote Files With ASP
    - The Real Basics of Functions in ASP
    - Enhancing Readability with ASP
    - Mimicking PHP's String Formatting Functions
    - Windows Server Hacks 12, 77, and 98
    - How to Sort a Multi-Dimensional Array
    - Developing an Information Management Tool wi...
    - What are Active Server Pages?
    - Getting Remote Pages with ASP
    - FTP’ing Files with ASP
    - Apply Single-Sign-On to Your Application





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
    Stay green...Green IT