eval
I have a script that creates new objects based on the value of a form
field. Basically, the code looks like this.
eval ('new ' + objType.value + '(val1, val2, val3');
objType is a select with the different types of objects you can create
as values.
I really don't like using eval, and it's causing problems, like if I
do something like the following:
eval ('localVar = new ' + objType.value + '(val1, val2, val3');
localVar should refer to a variable local to the calling object, but
with the eval approach it ends up being the local variable for the
scope from which the eval was first executed.
I could use a seitch statement, but this approach means I now have an
extra place where I need to change my code so I'd like to afford this
if possible.
Is there another approach to creating a new instance of an object
dependant on the value of some variable?
.
Relevant Pages
- Re: Name collisions in Monad
... We spent a lot of time working on the scoping rules in Monad. ... create a new scope when run, and variables _created_ in that new scope are ... script, call a function, or start a new instance of Windows Command ... $var is initially set to "init" in the function ... (microsoft.public.windows.server.scripting) - Re: Can com+ Hotfix Rollup Package 27 fix my memory problem with WSH. CreateObject/CreateScript?
... > these activities have effects that are felt outside of the scope of a script ... Of course in script, the object will be ... > Even the above definition makes no distinction between object variables ... a connection every time I read or write a key, ... (microsoft.public.scripting.wsh) - Re: One other related Q Re: basic Q: Only one way to make vars live outside of the scope of a functi
... >>> directly to the calling script, without having to use global variables ... to get multiple return items from a subprocedure. ... >>> better not to mix scope and use global variables for multiple return ... before terminating the object reference. ... (microsoft.public.scripting.vbscript) - Re: new to scripting.. the below script stops after first run..
... I have exports from my unix servers that aren't compatible with MS for a straight import so I've fiddled with the data, and now I want to just run the same script many times and pass it a bunch of parameters.. ... Echo Changing scope options ... Netsh dhcp server %server% scope %netid% add iprange %iprangestart% %iprangeend% BOTH> NUL ... (microsoft.public.windows.server.scripting) - Re: [MSH] WMI Help
... access the variable in the global scope whether or not the script is ... dot-sourced into the global scope then $script:class is equivalent to ... >> defined so it will search the stack and find it in the parent scope and ... (microsoft.public.windows.server.scripting) |
|