WebBuilder101 - Making the web happen!
Need Web Dev software? Here is the place to
Flash Point

Working with Local and Global variables in ASP


Global Variables

Global variables unlike Local Variables, persist throughout the lifetime of the script, not a procedure. In other words, they last for as long as the script is running. Let's see how they work.

<%strGlobal = "Global variables persist during the lifetime of the script."%>
<%=strGlobal%>

<% Sub Procedure_1 ( )
strText = "'This is a text string"%>
<%=strText%>
<%=strGlobal%>
<%End Sub%>

<% Sub Procedure_2 ( )
strText = "This is another text string"%>
<%=strText%>
<%=strGlobal%>
<%End Sub%>


<p>This is the result for the first procedure: <%Procedure_1( )%></p>
<p>This is the result for the second procedure: <%Procedure_2 ( )%></p>
<p>This is the result for the first procedure: <%Procedure_1( )%>, again."%>

See it in action

As you can see, it doesn't matter whether the procedures have ended or not, the Global variable still remains - that is for as long as the script is running.

Back to intro Next

.

 

More Resources
An Introduction to ASP
Working with Form Input
How to create a .txt file
ASP 101
Haneng
ASPworld
ASPfaq

Suggested Reading

Beginning Active Server Pages 3.0
JavaScript Bible
Red Hat Linux
Dreamweaver 3.0
HTML Bible



Download WB101 Wallpaper
• Web Builder 101 Wallpaper Get it!.
• Find out how to create your own Wallpaper Teach me!.
Sign up for our Newsletters
• Web Building Sign me Up!.
• Net Alert! Sign me Up!.
Need Help?
• Contact Support Click here.
• E-mail the Webmaster Click Here.
• Search Tips Click Here.

Webbuilder101.com © 1998 - 2003 Copyright and Terms of Use
Send mail to: webmaster@webbuilder101.com

» About » Support

» FAQ » What's New » MyLog

Web Builder 101 Web Builder 101 - Making the Web Happen Web Builder 101 - Making the Web Happen
.