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 int select_if_proc (struct trns_header *, struct ccase *);
37 static void select_if_free (struct trns_header *);
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)
73 return (expr_evaluate (((struct select_if_trns *) t)->e, c, 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 lex_match_id ("FILTER");
89 if (lex_match_id ("OFF"))
90 default_dict.filter_var[0] = 0;
96 v = parse_variable ();
100 if (v->type == ALPHA)
102 msg (SE, _("The filter variable must be numeric."));
106 if (v->name[0] == '#')
108 msg (SE, _("The filter variable may not be scratch."));
112 strcpy (default_dict.filter_var, v->name);
114 FILTER_before_TEMPORARY = !temporary;
120 /* Parses the PROCESS IF command. */
122 cmd_process_if (void)
124 struct expression *e;
126 lex_match_id ("PROCESS");
129 e = expr_parse (PXP_BOOLEAN);
136 lex_error (_("expecting end of command"));
142 msg (MW, _("Only last instance of this command is in effect."));
143 expr_free (process_if_expr);