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
29 #include "debug-print.h"
31 /* Parses the NUMERIC command. */
37 /* Names of variables to create. */
41 /* Format spec for variables to create. f.type==-1 if default is to
47 if (!parse_DATA_LIST_vars (&v, &nv, PV_NONE))
48 return CMD_PART_SUCCESS_MAYBE;
50 /* Get the optional format specification. */
53 if (!parse_format_specifier (&f, 0))
55 if (formats[f.type].cat & FCAT_STRING)
57 msg (SE, _("Format type %s may not be used with a numeric "
58 "variable."), fmt_to_string (&f));
64 msg (SE, _("`)' expected after output format."));
71 /* Create each variable. */
72 for (i = 0; i < nv; i++)
74 struct variable *new_var = dict_create_var (default_dict, v[i], 0);
76 msg (SE, _("There is already a variable named %s."), v[i]);
80 new_var->print = new_var->write = f;
85 for (i = 0; i < nv; i++)
89 while (lex_match ('/'));
91 return lex_end_of_command ();
93 /* If we have an error at a point where cleanup is required,
94 flow-of-control comes here. */
96 for (i = 0; i < nv; i++)
99 return CMD_PART_SUCCESS_MAYBE;
102 /* Parses the STRING command. */
108 /* Names of variables to create. */
112 /* Format spec for variables to create. */
115 /* Width of variables to create. */
120 if (!parse_DATA_LIST_vars (&v, &nv, PV_NONE))
121 return CMD_PART_SUCCESS_MAYBE;
123 if (!lex_force_match ('(')
124 || !parse_format_specifier (&f, 0))
126 if (!(formats[f.type].cat & FCAT_STRING))
128 msg (SE, _("Format type %s may not be used with a string "
129 "variable."), fmt_to_string (&f));
133 if (!lex_match (')'))
135 msg (SE, _("`)' expected after output format."));
151 /* Create each variable. */
152 for (i = 0; i < nv; i++)
154 struct variable *new_var = dict_create_var (default_dict, v[i],
157 msg (SE, _("There is already a variable named %s."), v[i]);
159 new_var->print = new_var->write = f;
163 for (i = 0; i < nv; i++)
167 while (lex_match ('/'));
169 return lex_end_of_command ();
171 /* If we have an error at a point where cleanup is required,
172 flow-of-control comes here. */
174 for (i = 0; i < nv; i++)
177 return CMD_PART_SUCCESS_MAYBE;
180 /* Parses the LEAVE command. */
189 if (!parse_variables (default_dict, &v, &nv, PV_NONE))
191 for (i = 0; i < nv; i++)
200 return lex_end_of_command ();