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/alloc.h>
28 #include <libpspp/message.h>
29 #include <libpspp/str.h>
31 /* Set variables' alignment
32 This is the alignment for GUI display only.
33 It affects nothing but GUIs
36 cmd_variable_alignment (struct lexer *lexer, struct dataset *ds)
46 if (!parse_variables (lexer, dataset_dict (ds), &v, &nv, PV_NONE))
49 if ( lex_force_match (lexer, '(') )
51 if ( lex_match_id (lexer, "LEFT"))
53 else if ( lex_match_id (lexer, "RIGHT"))
55 else if ( lex_match_id (lexer, "CENTER"))
63 lex_force_match (lexer, ')');
71 for( i = 0 ; i < nv ; ++i )
72 var_set_alignment (v[i], align);
74 while (lex_token (lexer) == '/')
79 while (lex_token (lexer) != '.');
83 /* Set variables' display width.
84 This is the width for GUI display only.
85 It affects nothing but GUIs
88 cmd_variable_width (struct lexer *lexer, struct dataset *ds)
96 if (!parse_variables (lexer, dataset_dict (ds), &v, &nv, PV_NONE))
99 if ( lex_force_match (lexer, '(') )
101 if ( lex_force_int (lexer))
105 lex_force_match (lexer, ')');
108 for( i = 0 ; i < nv ; ++i )
109 var_set_display_width (v[i], lex_integer (lexer));
111 while (lex_token (lexer) == '/')
116 while (lex_token (lexer) != '.');
120 /* Set variables' measurement level */
122 cmd_variable_level (struct lexer *lexer, struct dataset *ds)
131 if (!parse_variables (lexer, dataset_dict (ds), &v, &nv, PV_NONE))
134 if ( lex_force_match (lexer, '(') )
136 if ( lex_match_id (lexer, "SCALE"))
137 level = MEASURE_SCALE;
138 else if ( lex_match_id (lexer, "ORDINAL"))
139 level = MEASURE_ORDINAL;
140 else if ( lex_match_id (lexer, "NOMINAL"))
141 level = MEASURE_NOMINAL;
148 lex_force_match (lexer, ')');
156 for( i = 0 ; i < nv ; ++i )
157 var_set_measure (v[i], level);
160 while (lex_token (lexer) == '/')
165 while (lex_token (lexer) != '.');