LUA与C++交互(在LUA脚本里调用C++函数传参)

xiaoxiao2021-02-27  414

local ps=Monitor.GetHisDetail('mnX002')//lua脚本调用C++程序第一个参数为字符类型 local ps=Monitor.GetHisDetail(1642)//第一个参数为数字类型 if (lua_isnumber(L, 1)) { userID = lua_tointeger(L, 1); } else if (lua_isstring(L, 1)) { userID = tradeDtail_Data->getUserID(QString::fromLocal8Bit(lua_tostring(L, 1))); }//C++代码获取LUA传递的参数,这是正确写法 if (lua_isstring(L, 1))//当传递为数字的时候判断为字符类型的时候返回的是true { userID = tradeDtail_Data->getUserID(QString::fromLocal8Bit(lua_tostring(L, 1))); } else if (lua_isnumber(L, 1)) { userID = lua_tointeger(L, 1); }//经过比较当传递的参数为字符类型和数字类型的时候判断为字符类型都会通过
转载请注明原文地址: https://www.6miu.com/read-2439.html

最新回复(0)