如果您正在寻找在 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});
}