You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@royale.apache.org by GitBox <gi...@apache.org> on 2020/02/11 07:54:30 UTC

[GitHub] [royale-asjs] pashminakazi edited a comment on issue #713: Conversion of Numbers to Decimal is not working

pashminakazi edited a comment on issue #713: Conversion of Numbers to Decimal is not working
URL: https://github.com/apache/royale-asjs/issues/713#issuecomment-584513483
 
 
   On Clicking Convert Button fn_TestConversion function called
   ```
   protected function fn_TestConversion(event:MouseEvent):void
   			{
   				if( txtFrom.text=="")
   				{
   					Alert.show("You have specified an invalid 'From Unit' in Test Conversion.");
   					return;
   				}
   				var responder9:Responder = new Responder(fn_roListRH,fn_HandleFault);
    			 var token9:AsyncToken =roConvert.fn_EvaluteExpression(ur_functionname.text, txtFrom.text,ur_defaultvalue.text, Number(ur_roundfactor.text) );
   			 token9.addResponder(responder9);
    			 trace(token9); 
   
   				
   			}
   			
   ```
   This function is calling a java function
   ```
   public static String fn_EvaluteExpression(String Expression, String Value, String DValue, int RoundTo)
   	{
   		String lsReturn = DValue;
   		try{
   
   			ScriptEngineManager mgr = new ScriptEngineManager();
   			ScriptEngine engine = mgr.getEngineByName("JavaScript");
   			Expression = Expression.replaceAll("X", Value);
   			Expression = Expression.replaceAll("x", Value);
   			String foo = Expression;
   			double ldVal = fn_RoundDecimal(Double.parseDouble((engine.eval(foo).toString())), RoundTo);
   			lsReturn = String.valueOf(ldVal);
   		}
   		catch (Exception e) {}
   		return lsReturn;
   	}
   	
   ResultHandler : ```
   private function fn_roListRH(e:ResultEvent):void {
   				
   				var Value:String = e.result as String;
   				txtToUnit.text = Value;
   			}
   ```
   
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services