Next: , Up: Variables

2.5.1 Variable Name

A variable name is a string between 1 and VAR_NAME_LEN bytes long that satisfies the rules for PSPP identifiers (see Tokens). Variable names are mixed-case and treated case-insensitively.

— Macro: int VAR_NAME_LEN

Maximum length of a variable name, in bytes, currently 64.

Only one commonly useful function relates to variable names:

— Function: const char * var_get_name (const struct variable *var)

Returns var's variable name as a C string.

A few other functions are much more rarely used. Some of these functions are used internally by the dictionary implementation:

— Function: void var_set_name (struct variable *var, const char *new_name)

Changes the name of var to new_name, which must be a “plausible” name as defined below.

This function cannot be applied to a variable that is part of a dictionary. Use dict_rename_var instead (see Dictionary Renaming Variables).

— Function: bool var_is_valid_name (const char *name, bool issue_error)
— Function: bool var_is_plausible_name (const char *name, bool issue_error)

Tests name for validity or “plausibility.” Returns true if the name is acceptable, false otherwise. If the name is not acceptable and issue_error is true, also issues an error message explaining the violation.

A valid name is one that fully satisfies all of the requirements for variable names (see Tokens). A “plausible” name is simply a string whose length is in the valid range and that is not a reserved word. PSPP accepts plausible but invalid names as variable names in some contexts where the character encoding scheme is ambiguous, as when reading variable names from system files.

— Function: enum dict_class var_get_dict_class (const struct variable *var)

Returns the dictionary class of var's name (see Dictionary Class).