2

我在 deluge 脚本中有一个变量,我想在日志中显示它的数据类型。我试过这个,它报告没有函数类型():info type(my variable);

我也搜索过zoho deluge data typezoho deluge introspection但没有找到任何可操作的东西。

任何建议将不胜感激。

谢谢你。

2020-09-25 更新:

在在线 deluge 编辑器中,工具提示将在输入变量名称时显示变量的类型。这意味着编辑器中的 javascript 能够获取变量类型并显示它们。有洪水命令来做同样的事情吗?

4

2 回答 2

1

如果您正在寻找在 Zoho Creator 中获取变量数据类型的函数,我已经为您编写了一个函数:

string type(list var)
{
    v = var.get(0);
    if(v == null)
    {
        return "NULL";
    }
    try 
    {
        m = v.toMap();
        if(m != null)
        {
            return "MAP";
        }
    }
    catch (e)
    {
    }
    try 
    {
        m = v.get(0);
        if(m != null)
        {
            return "LIST";
        }
    }
    catch (e)
    {
    }
    try 
    {
        if(isNumber(v))
        {
            return "NUMBER";
        }
    }
    catch (e)
    {
    }
    try 
    {
        if(isText(v))
        {
            return "STRING";
        }
    }
    catch (e)
    {
    }
    try 
    {
        if(isDate(v))
        {
            return "DATE";
        }
    }
    catch (e)
    {
    }
    try 
    {
        if(isFile(v))
        {
            return "FILE";
        }
    }
    catch (e)
    {
    }
    try 
    {
        if(isNull(v))
        {
            return "NULL";
        }
    }
    catch (e)
    {
    }
    try 
    {
        if(v.isEmpty())
        {
            try 
            {
                v.add(1);
                return "LIST";
            }
            catch (e)
            {
            }
            return "MAP";
        }
    }
    catch (e)
    {
    }
    return "COLLECTION";
}

您可以使用以下功能对其进行测试:

void testType()
{
    info thisapp.type({50});
    info thisapp.type({"ABC"});
    info thisapp.type({"01-01-2010"});
    info thisapp.type({'01-01-2010'});
    info thisapp.type({{1,2,3}});
    info thisapp.type({{"a":"b"}});
    x = List();
    info thisapp.type({x});
    x = Map();
    info thisapp.type({x});
    csv_file = "\"Name\",\"Age\"\n\"Mathew\",\"20\"".tofile("sample.csv");
    info thisapp.type({csv_file});
    info thisapp.type({null});
    products = Collection("Creator":5,"CRM":2,"Mail":8);
    info thisapp.type({products});
}
于 2022-01-24T20:21:18.657 回答
0

您是否尝试过:

info myvariable;

无法获取数据类型。

于 2020-09-18T21:31:38.310 回答