Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to execute code as ASP?

Status
Not open for further replies.

brentnewbury

Programmer
May 1, 2001
30
GB
I posted a problem a few days ago about using templates.

The problem was that when I get the template of an Access database, and then Response.Write() the template, the asp within the template would not execute, because ASP just sends the Response.Write() straight to the browser without checking it or executing code.

I know that vBulletin uses templates, but they are coding in PHP, so, I got an illegal version of the internet to see the logic behind templates. (Please remember, I am not installing it or copying code from vBulletin, just using simple logic). I searches for ages, then I realised, that vBulletin use something called eval().

This is a function that does exactly what I needed, but it was in PHP. It checks the string

eval($template[home_page])

to see if there is any code then excutes any code, and THEN sends it to the browser...

My real question is:
DOES ANYONE KNOW OF ANY FUNCTION WITHIN ASP TO DO EXACTLY WHAT EVAL() DOES????????


Thnx for your time,
Brent Newbury

 
i'm looking for the same thing.
there is an eval function and execute function in asp but they can't extract the code from a template. they both can handle only asp code. so my thought was to use regexps, and extract the code from a page, but that's not good enough (like when you have loops and conditions).
if you find a solution please be sure to post it here. i really need it :)
 
i found the files, but how do i use them in asp script?
thanks

:)
 
Sorry to disapoint you lot, but I'm building forums, so I want a function that is already in ASP, not *maybe*. And when you are distributing forums (maybe at a cost), it ain't good to say "Oh, sorry sir, it wo't work on that host, it don't have this installed." It must work on any server that is powered by Microsoft IIS 4.+.

So I will say good bye to ASP and hello, again, to PHP!


Thnx every one for thier help, it is appreciated,
Brent Newbury
 
Sorry Brent

I was a bit too quick with my fingers. :-(

MSScript does what you want but client-side

For you stakadush

Cut and paste the code below into an empty Asp file.

Code:
<%@ Language=VBScript %>
<%
Option Explicit
response.buffer = true
response.expires = 0
Dim sc_Srv
Dim str_Srv
%>
<HTML>
<HEAD>
<SCRIPT LANGUAGE=vbscript>
<!--
Sub button1_onclick
	Dim sc ' This can't be early-bound!
	Dim strProgram
	strProgram = &quot;Sub Main&quot; & vbCrLf & _
	&quot;MsgBox &quot;&quot;Hello World&quot;&quot;&quot; & vbCrLf & _
	&quot;End Sub&quot;
	Set sc = CreateObject(&quot;ScriptControl&quot;)
	sc.language = &quot;VBScript&quot;
	sc.addcode strProgram
	sc.run &quot;Main&quot;

End Sub
-->
</SCRIPT>
</HEAD>
<BODY>
<P><INPUT id=button1 type=button value=Button name=button1></P>
</BODY>
</HTML>
 
Hi

Here i am again. :)

I have done some research and have come up with the 'execute/executeglobal' VBScript statements (function local and script global scope respectively.

I'm pretty sure they do what you want, but i haven't tested this thoroughly.

See a short example below

Mike

Code:
<%@ Language=VBScript %>
<HTML>
<HEAD>
</HEAD>
<BODY>
<%
' Define a sub (the string contents
' could come from a database)
' Notice the eval function to compare
' 2 values because execute treats
' the = sign as assignment symbol
'
' 2 possible syntaxes :
'
' Either separte all statements by :
' or embed vbCrLf in the string
'
' Note that the scope is local to the
' calling function 
' For global scope use the
' 'executeglobal statement
	Dim st,sf,s2
	st = &quot;In here&quot;
	sf = &quot;Out there&quot;
	s2 = &quot;In here too&quot;
	execute &quot;sub execproc: if eval(&quot;&quot;3>=2&quot;&quot;) then Response.Write st&quot; &_
	&quot; else Response.Write sf end if: End Sub:&quot;
'
	execute &quot;sub execproc2&quot; & vbCrLf & _
			&quot;Response.Write s2&quot; & vbCrLf & _
			&quot;End Sub&quot;
%>
<table>
<tr>
<td bgcolor=LightSkyBlue>
<% execproc %>
</td>
<td bgcolor=PaleGreen>
<% execproc2 %>
</td>
</table>
</BODY>
</HTML>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top