stop server.execute in the middle

J

JT

is it possible to somehow "jump out of" an ASP page that is executed from
another page via the Server.Execute method?

on the page being executed i have several instances where i need to stop the
execution and immediately shoot back to the calling page without running
through the rest of the code on the executed page.

im not sure if this is possible but any help would be much appreciated.

tia
jt
 
R

Ray at

Only if you include code in the page that you're executing to have it halt
in there. What criteria are you using to decide whether or not you'd like
the code to continue?

Ray at work
 
J

JT

thanks for the reply - what is the code to halt an executed page?

for example, if i encounter an error on the executed page, i want to stop
the execution and bounce back to the calling page.

something like RETURN???
 
R

Ray at

Assuming vbscript:

Unfortunately, VBScript doesn't have the error trapping capabilities of VB.
So, you can't just do a "on error GOTO SOMEWHERE" and have "exit sub" at the
somewhere label. But you can do:

On Error Resume Next
If Err.Number <> 0 Then Exit Sub

Example:

page1.asp:
<%
server.execute "page2.asp"
response.write "<br>page 2 was executed."
%>

page2.asp:
<%
Call Main()
Sub Main()
on error resume next
response.write "test line 1<br>"
x = 1/0
If err.number <> 0 Then Exit Sub
response.write "test line2"
End Sub
%>

Ray at work
 
J

JT

but im not executing a sub - im executing an ASP page.

your advice would work if i were using 'includes' rather than server.execute

i tried making the asp page called by the server.execute a subroutine - but
when i do this, it doesn't get executed???

for this case i want to avoid using an includes file

i must be misunderstanding something b/c this seems like it should be so
simple

thanks again
jt
 
R

Ray at

You could just encapsulate your code in a sub and call it at the top of the
page.

Ray at work
 
J

JT

ok sorry silly me i think i got it now

i made my executed page into a subroutine but i forgot to add a call to the
subroutine

asp1.asp :

Server.Execute("../asp2.asp")


asp2.asp :

Call AddPayment()

Sub AddPayment()

if error = true then
exit sub
end if

do something else

End Sub

thanks for the help
jt
 

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
473,772
Messages
2,569,593
Members
45,111
Latest member
VetaMcRae
Top