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
23 #include "dictionary.h"
30 /* SELECT IF transformation. */
34 struct expression *e; /* Test expression. */
37 static trns_proc_func select_if_proc;
38 static trns_free_func select_if_free;
40 /* Parses the SELECT IF transformation. */
45 struct select_if_trns *t;
47 e = expr_parse (EXPR_BOOLEAN);
54 lex_error (_("expecting end of command"));
58 t = xmalloc (sizeof *t);
59 t->h.proc = select_if_proc;
60 t->h.free = select_if_free;
62 add_transformation ((struct trns_header *) t);
67 /* Performs the SELECT IF transformation T on case C. */
69 select_if_proc (struct trns_header * t, struct ccase * c,
72 return (expr_evaluate (((struct select_if_trns *) t)->e, c,
73 case_num, NULL) == 1.0) - 2;
76 /* Frees SELECT IF transformation T. */
78 select_if_free (struct trns_header * t)
80 expr_free (((struct select_if_trns *) t)->e);
83 /* Parses the FILTER command. */
87 if (lex_match_id ("OFF"))
88 dict_set_filter (default_dict, NULL);
94 v = parse_variable ();
100 msg (SE, _("The filter variable must be numeric."));
104 if (dict_class_from_id (v->name) == DC_SCRATCH)
106 msg (SE, _("The filter variable may not be scratch."));
110 dict_set_filter (default_dict, v);
112 FILTER_before_TEMPORARY = !temporary;
118 /* Parses the PROCESS IF command. */
120 cmd_process_if (void)
122 struct expression *e;
124 e = expr_parse (EXPR_BOOLEAN);
131 lex_error (_("expecting end of command"));
137 msg (MW, _("Only last instance of this command is in effect."));
138 expr_free (process_if_expr);