list length, type in XML?

mhisted's Avatar

mhisted

07 Aug, 2017 07:37 PM

Hi Chris,

Is there an expression for the length of a list, or the type of a variable, in the XML?
I'd like to say
if type(var) == list
 action/assignment
or
if len(list) == 1
 action/assignment

thanks,
Mark

  1. Support Staff 1 Posted by Christopher Sta... on 07 Aug, 2017 07:52 PM

    Christopher Stawarz's Avatar

    Hi Mark,

    Recent nightly builds have a size function, which returns the number of characters in a string, the number of elements in a list or dictionary, or 0 for all other types.

    Currently, there's no function that returns the type of a value. That could be useful, though, so I'll add one.

    Cheers,
    Chris

  2. 2 Posted by mhisted on 07 Aug, 2017 09:15 PM

    mhisted's Avatar

    This is great, thanks.
    Mark

  3. Support Staff 3 Posted by Christopher Sta... on 09 Aug, 2017 07:46 PM

    Christopher Stawarz's Avatar

    Hi Mark,

    Starting with tonight's nightly build, the expression parser has a new function, type, that returns the data type of a value as a string (“boolean”, “integer”, “float”, “string”, “list”, or “dictionary”). For example:

    if (type(var) == 'list') {
        // Do something listy with var
        ...
    }
    

    Chris

  4. Christopher Stawarz closed this discussion on 12 Aug, 2017 03:30 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac