/LENGTH=@{NONE,length_in_lines@}
/MORE=@{ON,OFF@}
/WIDTH=@{NARROW,WIDTH,n_characters@}
+ /TNUMBERS=@{VALUES,LABELS,BOTH@}
(logging)
/JOURNAL=@{ON,OFF@} ['file-name']
@itemx MORE
@itemx PAGER
@itemx WIDTH
+@itemx TNUMBERS
+The TNUMBERS option sets the way in which values are displayed in output tables.
+The valid settings are VALUES, LABELS and BOTH.
+If TNUMBERS is set to VALUES, then all values are displayed with their literal value
+(which for a numeric value is a number and for a string value an alphanumeric string).
+If TNUMBERS is set to LABELS, then values are displayed using their assigned labels if any.
+(@xref{VALUE LABELS}.)
+If the a value has no label, then it will be displayed using its literal value.
+If TNUMBERS is set to BOTH, then values will be displayed with both their label
+(if any) and their literal value in parenthesis.
@end table
@cindex headers
@cindex more
@cindex pager
@cindex width
+@cindex tnumbers
Logging subcommands affect logging of commands executed to external
struct fmt_settings *styles;
enum settings_output_devices output_routing[SETTINGS_N_OUTPUT_TYPES];
+
+ enum settings_var_style var_output_style;
+ enum settings_value_style value_output_style;
};
static struct settings the_settings = {
{SETTINGS_DEVICE_LISTING | SETTINGS_DEVICE_TERMINAL,
SETTINGS_DEVICE_LISTING | SETTINGS_DEVICE_TERMINAL,
0,
- SETTINGS_DEVICE_LISTING | SETTINGS_DEVICE_TERMINAL}
+ SETTINGS_DEVICE_LISTING | SETTINGS_DEVICE_TERMINAL},
+
+ SETTINGS_VAR_STYLE_LABELS,
+ SETTINGS_VAL_STYLE_LABELS
};
/* Initializes the settings module. */
assert (type < SETTINGS_N_OUTPUT_TYPES);
return the_settings.output_routing[type] | SETTINGS_DEVICE_UNFILTERED;
}
+
+enum settings_value_style
+settings_get_value_style (void)
+{
+ return the_settings.value_output_style;
+}
+
+void
+settings_set_value_style (enum settings_value_style s)
+{
+ the_settings.value_output_style = s;
+}
+
+
+
+enum settings_var_style
+settings_get_var_style (void)
+{
+ return the_settings.var_output_style;
+}
bool settings_get_testing_mode (void);
void settings_set_testing_mode (bool);
+enum settings_var_style
+ {
+ SETTINGS_VAR_STYLE_NAMES,
+ SETTINGS_VAR_STYLE_LABELS,
+ SETTINGS_VAR_STYLE_BOTH
+ };
+
+enum settings_value_style
+ {
+ SETTINGS_VAL_STYLE_VALUES,
+ SETTINGS_VAL_STYLE_LABELS,
+ SETTINGS_VAL_STYLE_BOTH
+ };
+
+
+enum settings_value_style settings_get_value_style (void);
+enum settings_var_style settings_get_var_style (void);
+
+void settings_set_value_style (enum settings_value_style s);
+void settings_set_var_style (enum settings_value_style s);
+
+
enum behavior_mode {
ENHANCED, /* Use improved PSPP behavior. */
COMPATIBLE /* Be as compatible as possible. */
SETTINGS_N_OUTPUT_TYPES
};
+
+
void settings_set_output_routing (enum settings_output_type,
enum settings_output_devices);
enum settings_output_devices settings_get_output_routing (
#include "data/format.h"
#include "data/identifier.h"
#include "data/missing-values.h"
+#include "data/settings.h"
#include "data/value-labels.h"
#include "data/vardict.h"
#include "libpspp/assertion.h"
return val_labs_find (v->val_labs, value);
}
+/*
+ Append to STR the string representation of VALUE for variable V.
+ STR must be a pointer to an initialised struct string.
+*/
+static void
+append_value (const struct variable *v, const union value *value,
+ struct string *str)
+{
+ char *s = data_out (value, var_get_encoding (v), &v->print);
+ ds_put_cstr (str, s);
+ free (s);
+}
+
/* Append STR with a string representing VALUE for variable V.
That is, if VALUE has a label, append that label,
otherwise format VALUE and append the formatted string.
var_append_value_name (const struct variable *v, const union value *value,
struct string *str)
{
+ enum settings_value_style style = settings_get_value_style ();
const char *name = var_lookup_value_label (v, value);
- if (name == NULL)
+
+ switch (style)
{
- char *s = data_out (value, var_get_encoding (v), &v->print);
- ds_put_cstr (str, s);
- free (s);
- }
- else
- ds_put_cstr (str, name);
+ case SETTINGS_VAL_STYLE_VALUES:
+ append_value (v, value, str);
+ break;
+
+ case SETTINGS_VAL_STYLE_LABELS:
+ if (name == NULL)
+ append_value (v, value, str);
+ else
+ ds_put_cstr (str, name);
+ break;
+
+ case SETTINGS_VAL_STYLE_BOTH:
+ default:
+ append_value (v, value, str);
+ if (name != NULL)
+ {
+ ds_put_cstr (str, " (");
+ ds_put_cstr (str, name);
+ ds_put_cstr (str, ")");
+ }
+ break;
+ };
}
\f
/* Print and write formats. */
scompression=scompress:on/off;
scripttab=string "x==1" "one character long";
seed=custom;
+ tnumbers=custom;
tb1=string "x==3 || x==11" "3 or 11 characters long";
tbfonts=string;
undefined=undef:warn/nowarn;
return 1;
}
+static int
+stc_custom_tnumbers (struct lexer *lexer,
+ struct dataset *ds UNUSED,
+ struct cmd_set *cmd UNUSED, void *aux UNUSED)
+{
+ lex_match (lexer, T_EQUALS);
+
+ if (lex_match_id (lexer, "VALUES"))
+ {
+ settings_set_value_style (SETTINGS_VAL_STYLE_VALUES);
+ }
+ else if (lex_match_id (lexer, "LABELS"))
+ {
+ settings_set_value_style (SETTINGS_VAL_STYLE_LABELS);
+ }
+ else if (lex_match_id (lexer, "BOTH"))
+ {
+ settings_set_value_style (SETTINGS_VAL_STYLE_BOTH);
+ }
+ else
+ {
+ lex_error (lexer, _("expecting VALUES, LABELS or BOTH"));
+ return 0;
+ }
+
+ return 1;
+}
+
+
/* Parses the EPOCH subcommand, which controls the epoch used for
parsing 2-digit years. */
static int