sizeof()

Returns the length of a string, a dyn or a mapping variable.

Synopsis

unsigned sizeof(<type> var);

Parameters

Parameter Description
var The variable whose length is retuned.

Errors

missing/incorrect arguments

Description

Returns the length of a string, a dyn or a mapping variable. The length of an entry is returned. As you can see in the example below, the length 2 is returned for the mapping with two entries and length 15 for the string containing the sentence "The third value". The length of the string including the spaces is 15.

Example

The example returns the length of the three variables firstVal, secondVal und thirdVal:

main(mapping event)


{


  mapping m;


  m["firstVal"]= "The first value";


  m["secondVal"]= "The second value";


  string thirdVal = "The third value";


  dyn_string fourthVal = makeDynString("The fourth value");


  DebugN("Length of the mapping:",m,":",sizeof(m));


  DebugN("Length of the string:",thirdVal,":",sizeof(thirdVal));


  DebugN("Length of the dyn_string:",fourthVal, ":",sizeof(fourthVal));


}

The example outputs:

WCCOAui1:["Length of the mapping:"][mapping 2 items

WCCOAui1: "firstVal" : "The first value"

WCCOAui1: "secondVal" : "The second value"

WCCOAui1:][":"][2]

WCCOAui1:["Length of the string:"]["The third value"][":"][15]

WCCOAui1:["Length of the dyn_string:"][dyn_string 1 items

WCCOAui1: 1: "The fourth value"

WCCOAui1:][":"][1]

Assignment

Strings

Availability

UI, CTRL