Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_web_howto thread: The eval statement in JScript


Message #1 by "Magowan, Ryan(LIT)" <R.Magowan@L...> on Fri, 30 Mar 2001 19:54:14 +0100
I know this is not a javascript site but an ASP site but it seems to have

developed into a general web how to forum which is good because if you're

developing a web app you have to use a myriad of technologies. Any way I was

wondering if anyone could give me a good definition of the eval statement in

JScript. I'm using it in places but don't really understand how it works.

I'm thinking that it could be very useful for creating dynamic javascript

functions within ASP. If it works the way I think it works I could create a

generate jscript function as follows.



<SCRIPT language=Javascript>

	function VeryGenericFunction( strFunctionBody ) {

		eval(strFunctionBody)

	}

</SCRIPT>



strFunctionBody could then be created on the fly by an ASP.



Let me no what you think.



Thanks

Ryan



Message #2 by "Peter Lanoie" <planoie@e...> on Fri, 30 Mar 2001 17:32:08 -0500
Well, if you are already generating code dynamically in the first place with

ASP, why bother adding that additional step of the eval function. You can

just generate the ACTUAL function(s) in ASP.  Generally, the eval function

is used when you need to escentially generate JavaScript within JavaScript.



I wrote a little card game application that displays only a certain number

of cards (what's in a hand).  But I wanted to write really clean javascript

for the card mouseover actions. There are 104 images for the whole card set,

but wouldn't want all that extra code if I don't have those cards on the

page.  So I dynamically create all the javascript needed but only for the

cards that I'm using on that particular hand.  It works very well. I'm sure

I could refine it even more, but for now it's good.



Peter



-----Original Message-----

From: Magowan, Ryan(LIT) [mailto:R.Magowan@L...]

Sent: Friday, March 30, 2001 1:54 PM

To: ASP Web HowTo

Subject: [asp_web_howto] The eval statement in JScript





I know this is not a javascript site but an ASP site but it seems to have

developed into a general web how to forum which is good because if you're

developing a web app you have to use a myriad of technologies. Any way I was

wondering if anyone could give me a good definition of the eval statement in

JScript. I'm using it in places but don't really understand how it works.

I'm thinking that it could be very useful for creating dynamic javascript

functions within ASP. If it works the way I think it works I could create a

generate jscript function as follows.



<SCRIPT language=Javascript>

	function VeryGenericFunction( strFunctionBody ) {

		eval(strFunctionBody)

	}

</SCRIPT>



strFunctionBody could then be created on the fly by an ASP.



Let me no what you think.



Thanks

Ryan




  Return to Index