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 lex_match_id ("SELECT");
49 e = expr_parse (PXP_BOOLEAN);
56 lex_error (_("expecting end of command"));
60 t = xmalloc (sizeof *t);
61 t->h.proc = select_if_proc;
62 t->h.free = select_if_free;
64 add_transformation ((struct trns_header *) t);
69 /* Performs the SELECT IF transformation T on case C. */
71 select_if_proc (struct trns_header * t, struct ccase * c,
74 return (expr_evaluate (((struct select_if_trns *) t)->e, c,
75 case_num, NULL) == 1.0) - 2;
78 /* Frees SELECT IF transformation T. */
80 select_if_free (struct trns_header * t)
82 expr_free (((struct select_if_trns *) t)->e);
85 /* Parses the FILTER command. */
89 lex_match_id ("FILTER");
91 if (lex_match_id ("OFF"))
92 dict_set_filter (default_dict, NULL);
98 v = parse_variable ();
102 if (v->type == ALPHA)
104 msg (SE, _("The filter variable must be numeric."));
108 if (v->name[0] == '#')
110 msg (SE, _("The filter variable may not be scratch."));
114 dict_set_filter (default_dict, v);
116 FILTER_before_TEMPORARY = !temporary;
122 /* Parses the PROCESS IF command. */
124 cmd_process_if (void)
126 struct expression *e;
128 lex_match_id ("PROCESS");
131 e = expr_parse (PXP_BOOLEAN);
138 lex_error (_("expecting end of command"));
144 msg (MW, _("Only last instance of this command is in effect."));
145 expr_free (process_if_expr);