1 /* PSPP - computes sample statistics.
2 Copyright (C) 1997-9, 2000 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., 59 Temple Place - Suite 330, Boston, MA
30 #include "debug-print.h"
32 /* Parses the NUMERIC command. */
38 /* Names of variables to create. */
42 /* Format spec for variables to create. f.type==-1 if default is to
46 lex_match_id ("NUMERIC");
49 if (!parse_DATA_LIST_vars (&v, &nv, PV_NONE))
50 return CMD_PART_SUCCESS_MAYBE;
52 /* Get the optional format specification. */
55 if (!parse_format_specifier (&f, 0))
57 if (formats[f.type].cat & FCAT_STRING)
59 msg (SE, _("Format type %s may not be used with a numeric "
60 "variable."), fmt_to_string (&f));
66 msg (SE, _("`)' expected after output format."));
73 /* Create each variable. */
74 for (i = 0; i < nv; i++)
76 struct variable *new_var = create_variable (&default_dict, v[i],
79 msg (SE, _("There is already a variable named %s."), v[i]);
83 new_var->print = new_var->write = f;
89 for (i = 0; i < nv; i++)
93 while (lex_match ('/'));
95 return lex_end_of_command ();
97 /* If we have an error at a point where cleanup is required,
98 flow-of-control comes here. */
100 for (i = 0; i < nv; i++)
103 return CMD_PART_SUCCESS_MAYBE;
106 /* Parses the STRING command. */
112 /* Names of variables to create. */
116 /* Format spec for variables to create. */
119 /* Width of variables to create. */
122 lex_match_id ("STRING");
125 if (!parse_DATA_LIST_vars (&v, &nv, PV_NONE))
126 return CMD_PART_SUCCESS_MAYBE;
128 if (!lex_force_match ('(')
129 || !parse_format_specifier (&f, 0))
131 if (!(formats[f.type].cat & FCAT_STRING))
133 msg (SE, _("Format type %s may not be used with a string "
134 "variable."), fmt_to_string (&f));
138 if (!lex_match (')'))
140 msg (SE, _("`)' expected after output format."));
156 /* Create each variable. */
157 for (i = 0; i < nv; i++)
159 struct variable *new_var = create_variable (&default_dict, v[i],
162 msg (SE, _("There is already a variable named %s."), v[i]);
165 new_var->print = new_var->write = f;
171 for (i = 0; i < nv; i++)
175 while (lex_match ('/'));
177 return lex_end_of_command ();
179 /* If we have an error at a point where cleanup is required,
180 flow-of-control comes here. */
182 for (i = 0; i < nv; i++)
185 return CMD_PART_SUCCESS_MAYBE;
188 /* Parses the LEAVE command. */
197 lex_match_id ("LEAVE");
198 if (!parse_variables (NULL, &v, &nv, PV_NONE))
200 for (i = 0; i < nv; i++)
210 return lex_end_of_command ();