length

Table of Contents

Prototype: length(list)

Return type: int

Description: Returns the length of list.

This function can accept many types of data parameters.

Arguments:

  • list: string, in the range: .*

Example:

body common control
{
      bundlesequence => { "test" };
}

bundle agent test

{
  vars:
      "test" slist => {
                        1,2,3,
                        "one", "two", "three",
                        "long string",
                        "four", "fix", "six",
                        "one", "two", "three",
      };

      "length" int => length("test");
      "test_str" string => join(",", "test");

  reports:
      "The test list is $(test_str)";
      "The test list has $(length) elements";
}

Output:

R: The test list is 1,2,3,one,two,three,long string,four,fix,six,one,two,three
R: The test list has 13 elements

History: The collecting function behavior was added in 3.9.

See also: nth(), mergedata(), about collecting functions, and data documentation.