Calling a Block of ASP from Another

K

Keith

I have a block of ASP code (enclosed in <% .. %>).

How can I call that piece of code from another piece of similar code?

And can the code be in any order on the page for it to work?

Thanks
 
P

Patrice

Make it a function and use the "include" directive to make this function
available in another script.

My personal preference :
- is to include only files containg functions (so that all includes are done
at the beginning and I'm able to call the function later rather than being
forced to include the file where I want to "call" its code)
- is to have a main include file that takes care itself to include what is
needed in most pages (db, ui, or whatever else helper code). The current
page then includes the main include file and then those who stores rarely
used code.

Patrice
 
S

Steven Burn

Do you mean something like this........?

<%
SomethingOrOther = GimmeTheString
Response.Write SomethingOrOther

Function GimmeTheString()
GimmeTheString = "don't you just love it when things work as they
should?"
End Function
%>

--

Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!
 
E

Evertjan.

Keith wrote on 22 jun 2004 in microsoft.public.inetserver.asp.general:
I have a block of ASP code (enclosed in <% .. %>).

How can I call that piece of code from another piece of similar code?

You cannot "call" asp code.

Asp is only a platform for serverside programmlanguage codes.

Depending on the language used [jscript, vbscript, etc]
you van "call" a function in such code.
And can the code be in any order on the page for it to work?

Again that depends on the language used.
In general, functions can be declared in any order.
But main code has an order.

Example in Jscript:

<%@Language=jscript%>

<%
var t="hello world";
%>

<%
Response.write(t);
%>

Exchanging the order of these last two gives an error ;-)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,156
Messages
2,570,878
Members
47,413
Latest member
KeiraLight

Latest Threads

Top