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 /* SELECT IF transformation. */
33 struct expression *e; /* Test expression. */
36 static trns_proc_func select_if_proc;
37 static trns_free_func select_if_free;
39 /* Parses the SELECT IF transformation. */
44 struct select_if_trns *t;
46 e = expr_parse (PXP_BOOLEAN);
53 lex_error (_("expecting end of command"));
57 t = xmalloc (sizeof *t);
58 t->h.proc = select_if_proc;
59 t->h.free = select_if_free;
61 add_transformation ((struct trns_header *) t);
66 /* Performs the SELECT IF transformation T on case C. */
68 select_if_proc (struct trns_header * t, struct ccase * c,
71 return (expr_evaluate (((struct select_if_trns *) t)->e, c,
72 case_num, NULL) == 1.0) - 2;
75 /* Frees SELECT IF transformation T. */
77 select_if_free (struct trns_header * t)
79 expr_free (((struct select_if_trns *) t)->e);
82 /* Parses the FILTER command. */
86 if (lex_match_id ("OFF"))
87 dict_set_filter (default_dict, NULL);
93 v = parse_variable ();
99 msg (SE, _("The filter variable must be numeric."));
103 if (dict_class_from_id (v->name) == DC_SCRATCH)
105 msg (SE, _("The filter variable may not be scratch."));
109 dict_set_filter (default_dict, v);
111 FILTER_before_TEMPORARY = !temporary;
117 /* Parses the PROCESS IF command. */
119 cmd_process_if (void)
121 struct expression *e;
123 e = expr_parse (PXP_BOOLEAN);
130 lex_error (_("expecting end of command"));
136 msg (MW, _("Only last instance of this command is in effect."));
137 expr_free (process_if_expr);