Detect function's caller's ScriptEngine - Printable Version +- 0Day Forums (https://zeroday.vip) +-- Forum: Coding (https://zeroday.vip/Forum-Coding) +--- Forum: JScript (https://zeroday.vip/Forum-JScript) +--- Thread: Detect function's caller's ScriptEngine (/Thread-Detect-function-39-s-caller-39-s-ScriptEngine) |
Detect function's caller's ScriptEngine - weetlessu - 07-24-2023 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]( [To see links please register here] ) 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; } RE: Detect function's caller's ScriptEngine - postcibal497937 - 07-24-2023 I ended up keeping the `isJsObject` parameter. Since we were using VBScript most of the time, and JScript was only being used to build libraries, that worked fine. |