函数:checkTable 检查 UItable

函数名称:检查 UItable

函数功能:用于检测 UItable 是否合法,是的话返回一个 json,否则报错并提示具体属性错误

函数方法

UIjson = checkTable(UITable)

参数 类型 必填 说明
UITable table 需要检测的 UItable
返回值 类型 说明
UIjson string 可以给 showUI 函数使用的 json

函数示例

require "TSLib"--使用本函数库必须在脚本开头引用并将文件放到设备 lua 目录下
MyTable = {    --这是一个错误的 UItable,并且错的离谱
    ["style"]        =  "default",
    ["width"]        =  w,
    ["height"]       =  h,
    ["config"]       =  "save_01.dat",
    ["timer"]        =  99,
    ["orient"]       =  0,
    ["pagetype"]     =  "multi",
    ["title"]        =  "触动精灵脚本配置",
    ["cancelname"]   =  "取消",
    ["okname"]       =  "开始",
    pages            =
    {
        {
            {
                ["type"] = "Label",
                ["text"] = "第一页设置",
                ["size"] = "25",
                ["align"] = "center",
                ["color"] = "0,0,0",
            },
            {
                ["type"] = "RadioGroup",
                ["list"] = "选项 1,选项 2,选项 3,选项 4,选项 5,选项 6,选项 7",
                ["select"] = "1",
            },
        },{
            {
                ["type"] = "Label",
                ["text"] = "第二页设置",
                ["size"] = 25,
                ["align"] = "center",
                ["color"] = "0,0,0",
            },
            {
                ["type"] = "Edit",
                ["prompt"] = "请输入一个字母",
                ["text"] = "默认值",
                ["kbtype"] = "ascii",
            },
            {
                ["type"] = "Edit",
                ["prompt"] = "请输入一个数字",
                ["text"] = "默认值",
                ["kbtype"] = "number",
            },
        },{
            {
                ["type"] = "Label",
                ["text"] = 1,
                ["size"] = 25,
                ["align"] = "center",
                ["color"] = "0,0,0",
            },
            {
                ["type"] = "CheckBoxGroup",
                ["list"] = "选项 1,选项2 ,选项 3,选项 4,选项 5,选项 6,选项 7",
                ["select"] = "3@5",
            },
            {
                ["type"] = "ComboBox",
                ["list"] = "选项 1,选项 2,选项 3",
                ["select"] = 1,
                ["data"] = "子选项 1,子选项 2,子选项 3,子选项 4#,子选项 5,子选项 6,子选项 7#,子选项 8,子选项 9",
                ["source"] = "test"
            },
            {
                ["type"] = "ComboBox",
                ["select"] = "1",
                ["dataSource"] = "test"
            },
        }
    }   
}
showUI(checkTable(MyTable))

注意事项 程序将会报错,并回报以下错误:

  1. 第 1 页第 1 个控件 size 属性错误
  2. 第 3 页第 1 个控件 text 属性错误
  3. 第 3 页第 3 个控件 select 属性错误 有些控件并没有检测,这个函数只是检测会引起服务崩溃的控件,如果通过了检测却造成设备进入安全模式,请反馈给 QQ: 288562893。
Copyright 北京帮你玩科技有限公司 2023 all right reserved,powered by Gitbook该文章修订时间: 2024-03-06 17:50:18

results matching ""

    No results matching ""