ZohoCoder
ZohoCoder

Reputation: 433

Zoho Deluge: how to display the type of an object or variable?

I have a variable in a deluge script and I want to display its data type in the log. I tried this, which reports there is no function type(): info type(my variable);

Also I searched for zoho deluge data type and zoho deluge introspection but didn't find anything that was actionable.

Any suggestions will be appreciated.

Thank you.

2020-09-25 update:

In the online deluge editor, the tooltips will display the type of a variable as one enters the variable name. That means the javascript in the editor is able to get the variable types and display them. Is there a deluge command to do the same thing?

Upvotes: 4

Views: 4434

Answers (2)

Mohamed El-Refaie
Mohamed El-Refaie

Reputation: 845

If you are looking for a function to fetch the variable data type in Zoho Creator, I have written one for you:

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";
}

And you can use the following function to test it:

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});
}

Upvotes: 2

tjoghoro
tjoghoro

Reputation: 1

Have you tried just:

info myvariable;

It is not possible to get the data type.

Upvotes: 0

Related Questions