wood burning stoves 2.0*
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
JavaRanch » Java Forums » Frameworks » GWT
Bookmark "JSNI eval function returning float" Watch "JSNI eval function returning float" New topic
Author

JSNI eval function returning float

David Kowalski
Greenhorn

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: 10523
    
    9

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

ItDoesntWorkIsUseless
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
Bartender

Joined: Oct 14, 2005
Posts: 18902
    
    8

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?
 
 
subject: JSNI eval function returning float