Eval and Webclient

the eval in webclient procude different behaviour between two servers:

Server Dev
JDK Information
java.vm.name=Java HotSpot™ Client VM
java.vm.version=11.0-b16
java.vm.info=mixed mode, sharing
java.vm.vendor=Sun Microsystems Inc.
Operating System Information
os.name=Windows 2003
os.version=5.2
os.arch=x86
Everything is ok

Prod Server
JDK Information
java.vm.name=Java HotSpot™ Client VM
java.vm.version=11.3-b02
java.vm.info=mixed mode, sharing
java.vm.vendor=Sun Microsystems Inc.
Operating System Information
os.name=Windows 2003
os.version=5.2
os.arch=x86
I’ve got couldn’t eval the string …

Do you have any idea ?

And what is your question?

Sorry the question wasn’t really clear

I’ve got “couldn’t eval the string …” in the prod server log

Did you already have any strange eval behaviour between two java version ?

I noticed also a problem with eval()

I already created an issue in the support database. Case 217097

In Eclipse I get the following error:

Source not found for module [C:/Users/Martin/servoy_workspace_development/MOD_RSS_HTMLTree/globals.js#645(eval): 1]

what are you trying to eval?

Ive got mostly the error when i try to eval
myvariable = globals.myfunction()
or
myvariable = globals.myfunction(‘arg1’,‘arg2’)

Johan,

See my case 217097. I added some coding how I tried to eval.

I use eval() in several ways:

str = 'globals.myMethod'
if (eval(str))  // To test if method exists
{
eval(str)(args)
}

But also

str = 'globals.myVar'
if (eval(str) == 1) // To test if this variable has value 1

And also

str = 'globals.myVar'
if (some test)
  str += ' = 1'
else
 str += ' = 2';
eval(str)  // Set variable to 1 or 2

And also

str = 'globals.myVar'
if (some test)
  str += ' [1]'
else
 str += ' [2]';
str += ' = 3'
eval(str) // Give some array value the value 3

Of course these example are quite simple, but it shows the way eval() is used. I worked fine in 3.5 and some of the coding was originally written in 2.2!

By the way, I tried also the following and that is working, so it looks like it is perhaps eval() in combination with if-statement

str = 'globals.myVar'
val = eval(str)
if (val == 1) // To test if this variable has value 1

erdione:
Ive got mostly the error when i try to eval
myvariable = globals.myfunction()
or
myvariable = globals.myfunction(‘arg1’,‘arg2’)

so you are doing

eval(“myvariable = globals.myfunction()”);

why would you eval that?

martinh:
Johan,

See my case 217097. I added some coding how I tried to eval.

I use eval() in several ways:

why are you evalling that kind of stuff like that?

why not just

if (globals[‘mymethod’])
{
globals’mymethod’
}

way faster then evalling.

I eval that because for example myfunction can be dynamically change (in my case database driven)

myvariable = globals[dynamicname]();

should work fine and even better/faster.

jcompagner:

martinh:
Johan,

See my case 217097. I added some coding how I tried to eval.

I use eval() in several ways:

why are you evalling that kind of stuff like that?

why not just

if (globals[‘mymethod’])
{
globals’mymethod’
}

way faster then evalling.

Because mymethod is a variable name (callback method)

globals[variableHoldingTheNameOfTheMethodYouWantToCall]()

really guys, eval is almost never needed…

OK, I’ll see if I can change my code, but how about the following:

var _method = arguments[0];

if (eval(_method))
{
   eval(_method)()
}

And the argument that I get, is a method on a form

So Arguments 0 = forms.myForm.myMethod

function test()
{
	var name = "called"; // arguments[0];
	var argument = "from test";
	this[name](argument);
}

function called()
{
	application.output("called with argument: " + arguments[0])
}