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>
32 /* Set variables' alignment
33 This is the alignment for GUI display only.
34 It affects nothing but GUIs
37 cmd_variable_alignment (struct lexer *lexer, struct dataset *ds)
47 if (!parse_variables (lexer, dataset_dict (ds), &v, &nv, PV_NONE))
50 if ( lex_force_match (lexer, '(') )
52 if ( lex_match_id (lexer, "LEFT"))
54 else if ( lex_match_id (lexer, "RIGHT"))
56 else if ( lex_match_id (lexer, "CENTER"))
64 lex_force_match (lexer, ')');
72 for( i = 0 ; i < nv ; ++i )
73 var_set_alignment (v[i], align);
75 while (lex_token (lexer) == '/')
80 while (lex_token (lexer) != '.');
84 /* Set variables' display width.
85 This is the width for GUI display only.
86 It affects nothing but GUIs
89 cmd_variable_width (struct lexer *lexer, struct dataset *ds)
97 if (!parse_variables (lexer, dataset_dict (ds), &v, &nv, PV_NONE))
100 if ( lex_force_match (lexer, '(') )
102 if ( lex_force_int (lexer))
106 lex_force_match (lexer, ')');
109 for( i = 0 ; i < nv ; ++i )
110 var_set_display_width (v[i], lex_integer (lexer));
112 while (lex_token (lexer) == '/')
117 while (lex_token (lexer) != '.');
121 /* Set variables' measurement level */
123 cmd_variable_level (struct lexer *lexer, struct dataset *ds)
132 if (!parse_variables (lexer, dataset_dict (ds), &v, &nv, PV_NONE))
135 if ( lex_force_match (lexer, '(') )
137 if ( lex_match_id (lexer, "SCALE"))
138 level = MEASURE_SCALE;
139 else if ( lex_match_id (lexer, "ORDINAL"))
140 level = MEASURE_ORDINAL;
141 else if ( lex_match_id (lexer, "NOMINAL"))
142 level = MEASURE_NOMINAL;
149 lex_force_match (lexer, ')');
157 for( i = 0 ; i < nv ; ++i )
158 var_set_measure (v[i], level);
161 while (lex_token (lexer) == '/')
166 while (lex_token (lexer) != '.');