eval bug in 2.2rc4

Nice work on rc4. Have found one problem, though…‘Eval’ is now broken in the following situation (was working in rc3 and earlier):

var emp_lastX_field = "person_sn";                 // Name of last field
var emp_lastX_pk	 = eval( emp_lastX_field );     // PK value in field e.g. '5'

application.output( emp_lastX_pk)                  // Yields 'person_sn' (wrong!)

Should yield pk value of 5 (which it used to). Looks like ‘eval’ is not evaluating.

This is the error I get…

org.mozilla.javascript.EvaluatorException: Invalid JavaScript value of type org.mozilla.javascript.WrappedStringBuffer

Hi Jerry,

I can’t speak to the bug report - but a MUCH BETTER WAY of getting the value of a column (based on a variable) is to use:

var emp_lastX_field = "person_sn";                 // Name of last field
var emp_lastX_pk    = controller.getDataProviderValue(emp_lastX_field)

When you use “eval” it CANNOT be compiled and must be evaluated at runtime.

Bob…

The value stored in emp_lastX_field is actually a relationship plus dataprovider: gLoginID_to_employees.last_client_sn. The record pointed to by the relationship is not the selected record on any form. Is there a way to use getDataproviderValue when the value you’re trying to get is only accessible through a relationship and is not for a selected record on any form?

I’m also getting this error in rc4.

 var ctlrTop      = forms.ControllerTop;
  for (i=0; i < param2.length; i++) {
      btnObj = eval("ctlrTop.elements." + param2[i]);
      btnObj.setLocation(locationX, locationY);
      locationX = locationX + 85;
   }

I’m getting following error

setLocation is not a function.

Backer
Pilot Simple Software

Additional info on eval:

I had to change…

var emp_lastX_pk = eval( emp_lastX_field );

to

var emp_lastX_pk = eval( emp_lastX_field.toString() ); 

to get the eval statement to work again. Likewise, I had to change…

if ( eval( emp_lastX_field + " != " + pk ) )

to

if ( eval( emp_lastX_field.toString() ) != pk )

…so it does look like something’s happening with casting and strings.

I changed the eval("ctlrTop.elements." + param2*);* **
to * _ctlrTop.elements[param2*];*_ _*_
I have used this “eval” more than 100 times in a single solution, now I’m replacing it with the alternate one.
Kindly fix this bug asap.
___________________
Backer
Pilot Simple Software

I’m also getting an error using eval ()

the code handles navigation using the valuse from a dataprovider:

eval("forms."+formname).controller.show();

Worke falwlessly but now fails in rc4 with error: ‘The undefined value has no properties.’

Cheers
Harry

Harry, had the same issue somehwere else.

You can avoid using eval in this case:

forms[formname].controller.show();

also works and improves performance

Paul

Thanks very much, Paul

I filter in that change.

i would like to know, though, what has caused the problem to surface now in order to avoid falling into a similar trap at some future point !!

Cheers

Harry

What do you mean with knowing the problem? Have you followed the thread in Latest Releases regarding RC4?

There was an issue with eval(). Johan posted a URL of a new download of js.jar with the fix for the problem.

Paul