Eval In JScript implements the VBScript executeglobal function, and the function fexecuteglobal by shawl. Qiu
Note:
As the name suggests, executeglobal is to make local variables into global variables...
Although the implementation function is just a few lines...
However, there are too many principles in these lines, so I don't want to bother explaining them... Please digest them yourself.
Shawl. Qiu
2007-09-09
Http://blog.csdn.net/btbtd
Content: <% @ Language = "JavaScript" codePage = "65001" %>
<! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<HTML xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Title> shawl. Qiu template </title>
</Head>
<Body>
<%
Ftest ("J ");
Response. Write ("I:" + I + "<br/> ");
Response. Write (typeof (I) + "<HR/> ");
Response. Write ("F: <XMP>" + F + "</XMP> <br/> ");
Response. Write ("Global:" + typeof (f) + "<br/> ");
Response. Write ("J: <XMP>" + J + "</XMP> <br/> ");
Response. Write ("Global:" + typeof (j) + "<br/> ");
Function ftest (dynarg)
{
VaR I = 0;
Fexecuteglobal ("F", F );
Fexecuteglobal ("I", I );
If (dynarg) fexecuteglobal (dynarg, Eval (dynarg ));
Function J ()
{
Response. Write ("J saying hi. <br/> ");
}
Function f ()
{
Response. Write ("f saying hi. <br/> ");
}
}
Function fexecuteglobal (svar, VAR)
{// Shawl. Qiu code, void return
If (! Svar) throw new error ("Var name must be not empty! ");
Eval (svar + "= Var ");
} // Function fexecuteglobal (svar, VAR)
%>
</Body>
</Html>