I'm trying to determine a function's result depending on the caller's ScriptEngine:
//JScript
function doSomething()
{
if (ScriptEngine() === "VBScript")
return "this is VBScript";
else
return "this is JScript";
}
But the results are:
//JScript
var str = doSomething(); //"this is JScript"
//VBScript
Dim str : str = DoSomething() '"this is JScript"
The ScriptEngine()
function always returns its caller's engine name, but I would like to know the doSomething()
caller's engine name (without passing it as a parameter). Is there any way to do this in ASP?
The motivation behind this is that I wrote a JSON utility class to use in an ASP site. The parsing of the JSON string is done via eval
(using the validation that I found in this answer).
The result of eval
is a JScript object (with JScript arrays and JScript dates as properties). Then the user must specify a flag to tell the function if he wants the pure JScript object or if he wants a VBScript object (with arrays and dates converted to their VBScript equivalent). I would like to eliminate that parameter.
//JScript
function parseJson(jsonString, isJsObject)
{
var parsedObject = parsingLogic(jsonString);
if (!isJsObject) //Would like to replace by engine check
convertVbProperties(parsedObject);
return parsedObject;
}