1 /* PSPP - computes sample statistics.
2 Copyright (C) 1997-9, 2000, 2006 Free Software Foundation, Inc.
3 Written by Ben Pfaff <blp@gnu.org>.
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
26 #include <data/procedure.h>
27 #include <data/variable.h>
28 #include <language/command.h>
29 #include <language/lexer/format-parser.h>
30 #include <language/lexer/lexer.h>
31 #include <language/lexer/variable-parser.h>
32 #include <libpspp/message.h>
33 #include <libpspp/misc.h>
34 #include <libpspp/str.h>
37 #define _(msgid) gettext (msgid)
45 static int internal_cmd_formats (struct dataset *ds, int);
48 cmd_print_formats (struct dataset *ds)
50 return internal_cmd_formats (ds, FORMATS_PRINT);
54 cmd_write_formats (struct dataset *ds)
56 return internal_cmd_formats (ds, FORMATS_WRITE);
60 cmd_formats (struct dataset *ds)
62 return internal_cmd_formats (ds, FORMATS_PRINT | FORMATS_WRITE);
66 internal_cmd_formats (struct dataset *ds, int which)
72 /* Format to set the variables to. */
75 /* Numeric or string. */
86 if (!parse_variables (dataset_dict (ds), &v, &cv, PV_NUMERIC))
92 msg (SE, _("`(' expected after variable list."));
95 if (!parse_format_specifier (&f)
96 || !fmt_check_output (&f)
97 || !fmt_check_type_compat (&f, NUMERIC))
100 if (!lex_match (')'))
102 msg (SE, _("`)' expected after output format."));
106 for (i = 0; i < cv; i++)
108 if (which & FORMATS_PRINT)
110 if (which & FORMATS_WRITE)