#include <config.h>
#include "alloc.h"
#include "command.h"
+#include "dictionary.h"
#include "error.h"
-#include "expr.h"
+#include "expressions/public.h"
#include "lexer.h"
#include "str.h"
#include "var.h"
struct expression *e; /* Test expression. */
};
-static int select_if_proc (struct trns_header *, struct ccase *);
-static void select_if_free (struct trns_header *);
+static trns_proc_func select_if_proc;
+static trns_free_func select_if_free;
/* Parses the SELECT IF transformation. */
int
struct expression *e;
struct select_if_trns *t;
- lex_match_id ("SELECT");
- lex_match_id ("IF");
-
- e = expr_parse (PXP_BOOLEAN);
+ e = expr_parse (default_dict, EXPR_BOOLEAN);
if (!e)
return CMD_FAILURE;
/* Performs the SELECT IF transformation T on case C. */
static int
-select_if_proc (struct trns_header * t, struct ccase * c)
+select_if_proc (struct trns_header *t_, struct ccase *c,
+ int case_num)
{
- return (expr_evaluate (((struct select_if_trns *) t)->e, c, NULL) == 1.0) - 2;
+ struct select_if_trns *t = (struct select_if_trns *) t_;
+ return expr_evaluate_num (t->e, c, case_num) == 1.0 ? -1 : -2;
}
/* Frees SELECT IF transformation T. */
int
cmd_filter (void)
{
- lex_match_id ("FILTER");
-
if (lex_match_id ("OFF"))
- default_dict.filter_var[0] = 0;
+ dict_set_filter (default_dict, NULL);
else
{
struct variable *v;
return CMD_FAILURE;
}
- if (v->name[0] == '#')
+ if (dict_class_from_id (v->name) == DC_SCRATCH)
{
msg (SE, _("The filter variable may not be scratch."));
return CMD_FAILURE;
}
-
- strcpy (default_dict.filter_var, v->name);
+
+ dict_set_filter (default_dict, v);
FILTER_before_TEMPORARY = !temporary;
}
{
struct expression *e;
- lex_match_id ("PROCESS");
- lex_match_id ("IF");
-
- e = expr_parse (PXP_BOOLEAN);
+ e = expr_parse (default_dict, EXPR_BOOLEAN);
if (!e)
return CMD_FAILURE;