1 /* PSPP - a program for statistical analysis.
2 Copyright (C) 1997-9, 2000 Free Software Foundation, Inc.
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
22 #include <data/procedure.h>
23 #include <data/variable.h>
24 #include <language/command.h>
25 #include <language/lexer/lexer.h>
26 #include <language/lexer/variable-parser.h>
27 #include <libpspp/message.h>
28 #include <libpspp/str.h>
33 #define _(msgid) gettext (msgid)
35 /* Set variables' alignment
36 This is the alignment for GUI display only.
37 It affects nothing but GUIs
40 cmd_variable_alignment (struct lexer *lexer, struct dataset *ds)
50 if (!parse_variables (lexer, dataset_dict (ds), &v, &nv, PV_NONE))
53 if ( lex_force_match (lexer, '(') )
55 if ( lex_match_id (lexer, "LEFT"))
57 else if ( lex_match_id (lexer, "RIGHT"))
59 else if ( lex_match_id (lexer, "CENTER"))
67 lex_force_match (lexer, ')');
75 for( i = 0 ; i < nv ; ++i )
76 var_set_alignment (v[i], align);
78 while (lex_token (lexer) == '/')
83 while (lex_token (lexer) != '.');
87 /* Set variables' display width.
88 This is the width for GUI display only.
89 It affects nothing but GUIs
92 cmd_variable_width (struct lexer *lexer, struct dataset *ds)
101 if (!parse_variables (lexer, dataset_dict (ds), &v, &nv, PV_NONE))
104 if (!lex_force_match (lexer, '(') || !lex_force_int (lexer))
109 width = lex_integer (lexer);
111 if (!lex_force_match (lexer, ')'))
119 msg (SE, _("Variable display width must be a positive integer."));
123 width = MIN (width, 2 * MAX_STRING);
125 for( i = 0 ; i < nv ; ++i )
126 var_set_display_width (v[i], width);
128 while (lex_token (lexer) == '/')
133 while (lex_token (lexer) != '.');
137 /* Set variables' measurement level */
139 cmd_variable_level (struct lexer *lexer, struct dataset *ds)
148 if (!parse_variables (lexer, dataset_dict (ds), &v, &nv, PV_NONE))
151 if ( lex_force_match (lexer, '(') )
153 if ( lex_match_id (lexer, "SCALE"))
154 level = MEASURE_SCALE;
155 else if ( lex_match_id (lexer, "ORDINAL"))
156 level = MEASURE_ORDINAL;
157 else if ( lex_match_id (lexer, "NOMINAL"))
158 level = MEASURE_NOMINAL;
165 lex_force_match (lexer, ')');
173 for( i = 0 ; i < nv ; ++i )
174 var_set_measure (v[i], level);
177 while (lex_token (lexer) == '/')
182 while (lex_token (lexer) != '.');