File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes GWT and the fly likes JSNI eval function returning float Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Frameworks » GWT
Bookmark "JSNI eval function returning float" Watch "JSNI eval function returning float" New topic

JSNI eval function returning float

David Kowalski

Joined: Mar 06, 2013
Posts: 2
Hello guys, I have a problem, I'm in need of using eval function from inside gtw, that calculates my function gives as String, for example Math.cos(5+9); and returning float.
I have been trying around with

However I can't make it work even for int numbers, not even for 5+2. Any idea how to fix that?
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10768

David Kowalski wrote:
However I can't make it work even for int numbers, ...

What is the expected behavior and what is the observed behavior. Please TellTheDetails

Looking at the code you posted (mind you I do not work with JS), if I think logically, then I would say there is no "myVar" defined which you are trying to return.

[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Paul Clapham

Joined: Oct 14, 2005
Posts: 19891

So you're trying to evaluate this, if I understand it correctly:

I would expect that to assign a string with three characters to the "myVar" variable. I wouldn't expect that coercing that string to int would produce 7, either. But the fix should be pretty clear, shouldn't it?
I agree. Here's the link:
subject: JSNI eval function returning float
It's not a secret anymore!