Next: , Previous: Variable Name, Up: Variables


2.5.2 Variable Type and Width

A variable's type and width are the type and width of its values (see Values).

— Function: enum val_type var_get_type (const struct variable *var)

Returns the type of variable var.

— Function: int var_get_width (const struct variable *var)

Returns the width of variable var.

— Function: void var_set_width (struct variable *var, int width)

Sets the width of variable var to width. The width of a variable should not normally be changed after the variable is created, so this function is rarely used. This function cannot be applied to a variable that is part of a dictionary.

— Function: bool var_is_numeric (const struct variable *var)

Returns true if var is a numeric variable, false otherwise.

— Function: bool var_is_alpha (const struct variable *var)

Returns true if var is an alphanumeric (string) variable, false otherwise.

— Function: bool var_is_short_string (const struct variable *var)

Returns true if var is a string variable of width MAX_SHORT_STRING or less, false otherwise.

— Function: bool var_is_long_string (const struct variable *var)

Returns true if var is a string variable of width greater than MAX_SHORT_STRING, false otherwise.

— Function: size_t var_get_value_cnt (const struct variable *var)

Returns the number of union values needed to hold an instance of variable var. var_get_value_cnt (var) is equivalent to value_cnt_from_width (var_get_width (var)).