diff --git a/LUA_General.cpp b/LUA_General.cpp index 3ff741a..b870314 100644 --- a/LUA_General.cpp +++ b/LUA_General.cpp @@ -57,7 +57,26 @@ MyPrint( lua_State* L) //------------------------------------------------------------------------------- static int -SetContext( lua_State* L) +LuaEvalNumExpr( lua_State* L) +{ + // un solo parametro stringa : sExpr + string sExpr ; + LuaCheckParam( L, 1, sExpr) + LuaClearStack( L) ; + // valuto l'espressione + double dVal ; + bool bOk = ExeLuaEvalNumExpr( sExpr, &dVal) ; + // restituisco il risultato + if ( bOk) + LuaSetParam( L, dVal) ; + else + LuaSetParam( L) ; + return 1 ; +} + +//------------------------------------------------------------------------------- +static int +LuaSetContext( lua_State* L) { // un solo parametro intero int nGseCtx ; @@ -72,7 +91,7 @@ SetContext( lua_State* L) //------------------------------------------------------------------------------- static int -GetContext( lua_State* L) +LuaGetContext( lua_State* L) { // nessun parametro LuaClearStack( L) ; @@ -422,8 +441,9 @@ LuaInstallGeneral( LuaMgr& luaMgr) { bool bOk = ( &luaMgr != nullptr) ; bOk = bOk && luaMgr.RegisterFunction( "print", MyPrint) ; - bOk = bOk && luaMgr.RegisterFunction( "EgtSetContext", SetContext) ; - bOk = bOk && luaMgr.RegisterFunction( "EgtGetContext", GetContext) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtEvalNumExpr", LuaEvalNumExpr) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtSetContext", LuaSetContext) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtGetContext", LuaGetContext) ; bOk = bOk && luaMgr.RegisterFunction( "EgtPause", LuaPause) ; bOk = bOk && luaMgr.RegisterFunction( "EgtStartCounter", LuaStartCounter) ; bOk = bOk && luaMgr.RegisterFunction( "EgtStopCounter", LuaStopCounter) ;