ASP – Lifetime of Variables

A variable declared inside a procedure is created and destroyed every time the procedure is executed. No scripts outside the procedure can access or change the variable.

To declare variables accessible to more than one ASP file, declare them as session variables or application variables.

Session Variables

Session variables are used to store information about ONE single user, and are available to all pages in one application. Typically information stored in session variables are name, id, and preferences.

Application Variables

Application variables are also available to all pages in one application. Application variables are used to store information about ALL users in a specific application.

Procedures

The ASP source code can contain procedures and functions:

<html>

<head>

<%

sub vbproc(num1,num2)

response.write(num1*num2)

end sub

%>

</head>

<body>

Result:

</body>

</html>

Insert the <%@ language=”language” %> line above the tag to write procedures or functions in another scripting language than default:

<%@ language=”javascript” %>

<html>

<head>

<%

function jsproc(num1,num2)

{

Response.Write(num1*num2)

}

%>

</head>

<body>

Result:

</body>

</html>

Reference : Dilip Kumar Jena ( https://mstechexplore.wordpress.com )

Advertisements

One thought on “ASP – Lifetime of Variables

  1. I simply want to mention I am very new to weblog and definitely liked you’re page. More than likely I’m planning to bookmark your blog post . You definitely come with perfect well written articles. Appreciate it for sharing with us your website page.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s