【AndroLua+】一个编辑器语法错误检查例子

avatar

azurekiln

-- LuaStudio+ 错误检查提示栏
function check_code_main()
  if check_opened_file() then
    local file_path=opened_file.Text
    if file_path:find("%.lua") or file_path:find("%.aly") then
      local src=editor.getText()
      src=src.toString()
      if file_path:find("%.aly$") then
        src="return "..src
      end
      local _,data=loadstring(src)
      if data then
        local _,_,line,data=data:find(".(%d+).(.+)")
        error_text_id.setText(line..":"..data)
        error_text_id.setTextColor(pc(0xffff0000))
        return true
       else
        error_text_id.setTextColor(pc(text_color))
        error_text_id.setText("No Error.")
        return false
      end
    end
  end
end

扫描二维码,在手机上阅读
收藏
请先 登录 再评论
powered by emlog pro
服务器供应商 新区云数据

友情链接
白衣Ink


sitemap